public class FutureTransformUtils {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private FutureTransformUtils() {
+ }
+
public static final ListenableFuture<List<OperationResult>> transformTransactResponse(
ListenableFuture<List<JsonNode>> transactResponseFuture, final List<Operation> operations) {
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private static final Logger LOG = LoggerFactory.getLogger(OvsdbClientImpl.class);
private ExecutorService executorService;
private OvsdbRPC rpc;
- private Map<String, DatabaseSchema> schema = Maps.newHashMap();
+ private Map<String, DatabaseSchema> schemas = Maps.newHashMap();
private Map<String, CallbackContext> monitorCallbacks = Maps.newHashMap();
private OvsdbRPC.Callback rpcCallback;
private OvsdbConnectionInfo connectionInfo;
}
/**
- * Genereate the threadFactory based on ACTIVE, PASSIVE (SSL/NON-SSL) connection type.
+ * Generate the threadFactory based on ACTIVE, PASSIVE (SSL/NON-SSL) connection type.
* @param type ACTIVE or PASSIVE {@link ConnectionType}
* @param socketConnType SSL or NON-SSL {@link SocketConnectionType}
* @param executorNameArgs Additional args to append to thread name format
for (Iterator<Map.Entry<String,JsonNode>> itr = updatesJson.fields(); itr.hasNext();) {
Map.Entry<String, JsonNode> entry = itr.next();
- DatabaseSchema databaseSchema = this.schema.get(dbSchema.getName());
+ DatabaseSchema databaseSchema = this.schemas.get(dbSchema.getName());
TableSchema table = databaseSchema.table(entry.getKey(), TableSchema.class);
tableUpdateMap.put(entry.getKey(), table.updatesFromJson(entry.getValue()));
public boolean isReady(int timeout) throws InterruptedException {
while (timeout > 0) {
- if (!schema.isEmpty()) {
+ if (!schemas.isEmpty()) {
return true;
}
Thread.sleep(1000);
@Override
public ListenableFuture<DatabaseSchema> getSchema(final String database) {
- DatabaseSchema databaseSchema = schema.get(database);
+ DatabaseSchema databaseSchema = schemas.get(database);
if (databaseSchema == null) {
return Futures.transform(
if (result.containsKey(database)) {
DatabaseSchema dbSchema = result.get(database);
dbSchema.populateInternallyGeneratedColumns();
- OvsdbClientImpl.this.schema.put(database, dbSchema);
+ OvsdbClientImpl.this.schemas.put(database, dbSchema);
return dbSchema;
} else {
return null;
@Override
public DatabaseSchema getDatabaseSchema(String dbName) {
- return schema.get(dbName);
+ return schemas.get(dbName);
}
/**
JsonParser jp = jacksonJsonFactory.createParser(new ByteBufInputStream(slice));
JsonNode root = jp.readValueAsTree();
out.add(root);
- leftCurlies = rightCurlies = lastRecordBytes = 0;
+ leftCurlies = 0;
+ rightCurlies = 0;
+ lastRecordBytes = 0;
recordsRead++;
break;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.ovsdb.lib.jsonrpc;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
-
public class JsonUtils {
- static ObjectMapper mapper = new ObjectMapper();
+ private static ObjectMapper mapper = new ObjectMapper();
+ private static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
- static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
+ private JsonUtils() {
+ }
public static String prettyString(Object jsonNode) {
try {
}
public MonitorRequest build() {
- MonitorRequest monitorRequest = getMonitorRequest();
- if (monitorRequest.getSelect() == null) {
- monitorRequest.setSelect(new MonitorSelect());
+ MonitorRequest newBuiltMonitorRequest = getMonitorRequest();
+ if (newBuiltMonitorRequest.getSelect() == null) {
+ newBuiltMonitorRequest.setSelect(new MonitorSelect());
}
- monitorRequest.setTableName(tableSchema.getName());
- return monitorRequest;
+ newBuiltMonitorRequest.setTableName(tableSchema.getName());
+ return newBuiltMonitorRequest;
}
}
return oldRow;
}
- public void setOld(Row<E> oldRow) {
- this.oldRow = oldRow;
+ public void setOld(Row<E> old) {
+ this.oldRow = old;
}
public Row<E> getNew() {
return newRow;
}
+ @SuppressWarnings("checkstyle:HiddenField")
public void setNew(Row<E> newRow) {
this.newRow = newRow;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.ovsdb.lib.notation;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
-
public class Column<E extends TableSchema<E>, D> {
@JsonIgnore
private ColumnSchema<E, D> schema;
this.data = data;
}
- public <E extends TableSchema<E>, T> T getData(ColumnSchema<E, T> schema) {
- return schema.validate(data);
+ public <E extends TableSchema<E>, T> T getData(ColumnSchema<E, T> anotherSchema) {
+ return anotherSchema.validate(data);
}
public D getData() {
@Override
protected void getConstraints(IntegerBaseType baseType, JsonNode type) {
-
- JsonNode node = null;
-
- if ((node = type.get("maxInteger")) != null) {
- baseType.setMax(node.asLong());
+ JsonNode typeMaxNode = type.get("maxInteger");
+ if (typeMaxNode != null) {
+ baseType.setMax(typeMaxNode.asLong());
}
-
- if ((node = type.get("minInteger")) != null) {
- baseType.setMin(node.asLong());
+ JsonNode typeMinNode = type.get("minInteger");
+ if (typeMinNode != null) {
+ baseType.setMin(typeMinNode.asLong());
}
-
populateEnum(type);
}
private void populateEnum(JsonNode node) {
if (node.has("enum")) {
- Set<Long> enums = Sets.newHashSet();
+ Set<Long> nodesEnums = Sets.newHashSet();
JsonNode anEnum = node.get("enum").get(1);
for (JsonNode enm : anEnum) {
- enums.add(enm.asLong());
+ nodesEnums.add(enm.asLong());
}
}
}
@Override
protected void getConstraints(RealBaseType baseType, JsonNode type) {
-
- JsonNode node;
-
- if ((node = type.get("maxReal")) != null) {
- baseType.setMax(node.asLong());
+ JsonNode typeMaxNode = type.get("maxReal");
+ if (typeMaxNode != null) {
+ baseType.setMax(typeMaxNode.asLong());
}
-
- if ((node = type.get("minReal")) != null) {
- baseType.setMin(node.asLong());
+ JsonNode typeMinNode = type.get("minReal");
+ if (typeMinNode != null) {
+ baseType.setMin(typeMinNode.asLong());
}
-
populateEnum(type);
}
private void populateEnum(JsonNode node) {
if (node.has("enum")) {
- Set<Double> enums = Sets.newHashSet();
+ Set<Double> nodesEnums = Sets.newHashSet();
JsonNode anEnum = node.get("enum").get(1);
for (JsonNode enm : anEnum) {
- enums.add(enm.asDouble());
+ nodesEnums.add(enm.asDouble());
}
}
}
@Override
protected void getConstraints(StringBaseType baseType, JsonNode type) {
-
- JsonNode node = null;
-
- if ((node = type.get("maxLength")) != null) {
- baseType.setMaxLength(node.asInt());
+ JsonNode typeMaxNode = type.get("maxLength");
+ if (typeMaxNode != null) {
+ baseType.setMaxLength(typeMaxNode.asInt());
}
-
- if ((node = type.get("minLength")) != null) {
- baseType.setMinLength(node.asInt());
+ JsonNode typeMinNode = type.get("minLength");
+ if (typeMinNode != null) {
+ baseType.setMinLength(typeMinNode.asInt());
}
-
populateEnum(baseType, type);
}
private void populateEnum(StringBaseType baseType, JsonNode node) {
if (node.has("enum")) {
- Set<String> enums = Sets.newHashSet();
+ Set<String> nodesEnums = Sets.newHashSet();
JsonNode enumVal = node.get("enum");
if (enumVal.isArray()) {
JsonNode anEnum = enumVal.get(1);
for (JsonNode enm : anEnum) {
- enums.add(enm.asText());
+ nodesEnums.add(enm.asText());
}
} else if (enumVal.isTextual()) {
- enums.add(enumVal.asText());
+ nodesEnums.add(enumVal.asText());
}
- baseType.setEnums(enums);
+ baseType.setEnums(nodesEnums);
}
}
String refTable;
RefType refType;
-
@Override
public UuidBaseType fromString(String typeString) {
return "uuid".equals(typeString) ? new UuidBaseType() : null;
@Override
protected void getConstraints(UuidBaseType baseType, JsonNode node) {
-
- JsonNode refTable = node.get("refTable");
- baseType.setRefTable(refTable != null ? refTable.asText() : null);
+ JsonNode refTableNode = node.get("refTable");
+ baseType.setRefTable(refTableNode != null ? refTableNode.asText() : null);
JsonNode refTypeJson = node.get("refType");
baseType.setRefType(refTypeJson != null ? RefType.valueOf(refTypeJson.asText()) : RefType.strong);
-
}
@Override
/**
* Verifies if this Column if of the specified type.
- * @param type the type to check for
+ * @param typeClass the type to check for
*/
- public void validateType(Class<?> type) {
+ public void validateType(Class<?> typeClass) {
}
AtomicColumnType atomicColumnType = new AtomicColumnType(jsonBaseType);
- JsonNode node;
- if ((node = json.get("min")) != null) {
- atomicColumnType.setMin(node.asLong());
+ JsonNode minNode = json.get("min");
+ if (minNode != null) {
+ atomicColumnType.setMin(minNode.asLong());
}
- if ((node = json.get("max")) != null) {
- if (node.isNumber()) {
- atomicColumnType.setMax(node.asLong());
- } else if ("unlimited".equals(node.asText())) {
+ JsonNode maxNode = json.get("max");
+ if (maxNode != null) {
+ if (maxNode.isNumber()) {
+ atomicColumnType.setMax(maxNode.asLong());
+ } else if ("unlimited".equals(maxNode.asText())) {
atomicColumnType.setMax(Long.MAX_VALUE);
}
}
BaseType valueType = BaseType.fromJson(json, "value");
KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(jsonKeyType, valueType);
- JsonNode node;
- if ((node = json.get("min")) != null) {
- keyValueColumnType.setMin(node.asLong());
+ JsonNode minNode = json.get("min");
+ if (minNode != null) {
+ keyValueColumnType.setMin(minNode.asLong());
}
- if ((node = json.get("max")) != null) {
- if (node.isLong()) {
- keyValueColumnType.setMax(node.asLong());
- } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+ JsonNode maxNode = json.get("max");
+ if (maxNode != null) {
+ if (maxNode.isLong()) {
+ keyValueColumnType.setMax(maxNode.asLong());
+ } else if (maxNode.isTextual() && "unlimited".equals(maxNode.asText())) {
keyValueColumnType.setMax(Long.MAX_VALUE);
}
}
}
public Row<E> createRow(ObjectNode rowNode) {
- List<Column<E, ?>> columns = new ArrayList<>();
+ List<Column<E, ?>> newColumns = new ArrayList<>();
for (Iterator<Map.Entry<String, JsonNode>> iter = rowNode.fields(); iter.hasNext();) {
Map.Entry<String, JsonNode> next = iter.next();
ColumnSchema<E, Object> schema = column(next.getKey(), Object.class);
*/
if (schema != null) {
Object value = schema.valueFromJson(next.getValue());
- columns.add(new Column<>(schema, value));
+ newColumns.add(new Column<>(schema, value));
}
}
- return new Row<>(this, columns);
+ return new Row<>(this, newColumns);
}
public List<Row<E>> createRows(JsonNode rowsNode) {