├── .gitignore
├── ovsdb-client
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── ovsdb-client.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── vmware
│ │ │ └── ovsdb
│ │ │ ├── protocol
│ │ │ ├── operation
│ │ │ │ ├── package-info.java
│ │ │ │ ├── notation
│ │ │ │ │ ├── package-info.java
│ │ │ │ │ ├── Value.java
│ │ │ │ │ ├── Mutator.java
│ │ │ │ │ ├── serializer
│ │ │ │ │ │ ├── RowSerializer.java
│ │ │ │ │ │ └── AtomSerializer.java
│ │ │ │ │ ├── deserializer
│ │ │ │ │ │ ├── RowDeserializer.java
│ │ │ │ │ │ ├── NamedUuidDeserializer.java
│ │ │ │ │ │ ├── ConditionDeserializer.java
│ │ │ │ │ │ ├── PairDeserializer.java
│ │ │ │ │ │ ├── ValueDeserializer.java
│ │ │ │ │ │ ├── MapDeserializer.java
│ │ │ │ │ │ ├── UuidDeserializer.java
│ │ │ │ │ │ ├── AtomDeserializer.java
│ │ │ │ │ │ └── SetDeserializer.java
│ │ │ │ │ ├── Function.java
│ │ │ │ │ ├── Uuid.java
│ │ │ │ │ ├── Pair.java
│ │ │ │ │ ├── NamedUuid.java
│ │ │ │ │ ├── Atom.java
│ │ │ │ │ └── Map.java
│ │ │ │ ├── result
│ │ │ │ │ ├── EmptyResult.java
│ │ │ │ │ ├── UpdateResult.java
│ │ │ │ │ ├── SelectResult.java
│ │ │ │ │ ├── InsertResult.java
│ │ │ │ │ └── OperationResult.java
│ │ │ │ ├── Abort.java
│ │ │ │ ├── Operation.java
│ │ │ │ ├── Assert.java
│ │ │ │ ├── Commit.java
│ │ │ │ └── Comment.java
│ │ │ ├── schema
│ │ │ │ ├── package-info.java
│ │ │ │ ├── BooleanBaseType.java
│ │ │ │ ├── AtomicType.java
│ │ │ │ ├── RealBaseType.java
│ │ │ │ ├── UuidBaseType.java
│ │ │ │ ├── StringBaseType.java
│ │ │ │ ├── IntegerBaseType.java
│ │ │ │ └── deserializer
│ │ │ │ │ └── TypeDeserializer.java
│ │ │ └── methods
│ │ │ │ ├── package-info.java
│ │ │ │ ├── serializer
│ │ │ │ └── MonitorRequestsSerializer.java
│ │ │ │ ├── deserializer
│ │ │ │ ├── TableUpdateDeserializer.java
│ │ │ │ └── TableUpdatesDeserializer.java
│ │ │ │ ├── TableUpdate.java
│ │ │ │ ├── TableUpdates.java
│ │ │ │ ├── MonitorRequests.java
│ │ │ │ ├── LockResult.java
│ │ │ │ ├── RowUpdate.java
│ │ │ │ └── MonitorRequest.java
│ │ │ ├── exception
│ │ │ └── OvsdbClientException.java
│ │ │ ├── callback
│ │ │ ├── LockCallback.java
│ │ │ ├── MonitorCallback.java
│ │ │ └── ConnectionCallback.java
│ │ │ ├── netty
│ │ │ ├── ExceptionHandler.java
│ │ │ └── JsonNodeDecoder.java
│ │ │ ├── service
│ │ │ ├── OvsdbActiveConnectionConnector.java
│ │ │ ├── OvsdbPassiveConnectionListener.java
│ │ │ └── impl
│ │ │ │ └── OvsdbActiveConnectionConnectorImpl.java
│ │ │ └── util
│ │ │ └── PropertyManager.java
│ └── test
│ │ ├── resources
│ │ ├── ovsdb-client.properties
│ │ └── log4j.properties
│ │ └── java
│ │ └── com
│ │ └── vmware
│ │ └── ovsdb
│ │ ├── testutils
│ │ ├── HardwareGatewayConstants.java
│ │ ├── TestConstants.java
│ │ └── ActiveOvsdbServerEmulator.java
│ │ ├── protocol
│ │ ├── schema
│ │ │ ├── Constants.java
│ │ │ ├── BaseTypeTest.java
│ │ │ ├── DatabaseSchemaTest.java
│ │ │ ├── ColumnSchemaTest.java
│ │ │ ├── AtomicTypeTest.java
│ │ │ ├── BooleanBaseTypeTest.java
│ │ │ └── RealBaseTypeTest.java
│ │ ├── operation
│ │ │ ├── AbortTest.java
│ │ │ ├── AssertTest.java
│ │ │ ├── result
│ │ │ │ ├── UpdateResultTest.java
│ │ │ │ ├── InsertResultTest.java
│ │ │ │ ├── EmptyResultTest.java
│ │ │ │ └── ErrorResultTest.java
│ │ │ ├── CommentTest.java
│ │ │ ├── CommitTest.java
│ │ │ ├── notation
│ │ │ │ ├── MutationTest.java
│ │ │ │ ├── NamedUuidTest.java
│ │ │ │ ├── UuidTest.java
│ │ │ │ ├── ValueTest.java
│ │ │ │ ├── MapTest.java
│ │ │ │ ├── PairTest.java
│ │ │ │ ├── ConditionTest.java
│ │ │ │ └── SetTest.java
│ │ │ └── InsertTest.java
│ │ └── methods
│ │ │ ├── LockResultTest.java
│ │ │ ├── MonitorSelectTest.java
│ │ │ └── TableUpdateTest.java
│ │ ├── util
│ │ └── PropertyManagerTest.java
│ │ └── service
│ │ ├── OvsdbClientActiveConnectionTest.java
│ │ └── OvsdbClientPassiveConnectionTest.java
└── pom.xml
├── json-rpc
├── src
│ ├── test
│ │ ├── resources
│ │ │ └── log4j.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── vmware
│ │ │ └── ovsdb
│ │ │ └── jsonrpc
│ │ │ └── v1
│ │ │ ├── util
│ │ │ ├── TestUtil.java
│ │ │ └── JsonUtilTest.java
│ │ │ ├── model
│ │ │ ├── JsonRpcV1ResponseTest.java
│ │ │ └── JsonRpcV1RequestTest.java
│ │ │ └── service
│ │ │ └── domain
│ │ │ └── SillyCalculator.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── vmware
│ │ └── ovsdb
│ │ └── jsonrpc
│ │ └── v1
│ │ ├── exception
│ │ ├── JsonRpcDuplicateIdException.java
│ │ ├── JsonRpcConnectionClosedException.java
│ │ ├── JsonRpcInvalidResponseException.java
│ │ ├── JsonRpcResultTypeMismatchException.java
│ │ ├── JsonRpcTransportException.java
│ │ └── JsonRpcException.java
│ │ ├── util
│ │ └── JsonRpcConstant.java
│ │ ├── annotation
│ │ └── JsonRpcServiceMethod.java
│ │ ├── spi
│ │ └── JsonRpcTransporter.java
│ │ └── service
│ │ ├── JsonRpcV1Server.java
│ │ └── JsonRpcV1Client.java
└── pom.xml
├── NOTICE
├── .travis.yml
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | *.iml
3 | target/*
4 | */target/*
5 | .DS_Store
6 |
7 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/resources/ovsdb-client.properties:
--------------------------------------------------------------------------------
1 | channel.read.idle.timeout.sec=30
2 | channel.read.idle.max=3
3 | rpc.timeout.sec=60
4 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/resources/ovsdb-client.properties:
--------------------------------------------------------------------------------
1 | channel.read.idle.timeout.sec=5
2 | channel.read.idle.max=3
3 | rpc.timeout.sec=10
4 |
5 | invalid.int=abc
6 |
--------------------------------------------------------------------------------
/json-rpc/src/test/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG
2 | log4j.rootLogger=DEBUG, stdout
3 | # Direct log messages to stdout
4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 | log4j.appender.stdout.Target=System.out
6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.stdout.layout.ConversionPattern=%d | %-5.5p | %-15.50t | %-25.50c{1} | %m%n
8 |
9 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG
2 | log4j.rootLogger=DEBUG, stdout
3 | # Reduce debug log from apache
4 | log4j.logger.org.apache=info
5 | # Direct log messages to stdout
6 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
7 | log4j.appender.stdout.Target=System.out
8 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.stdout.layout.ConversionPattern=%d | %-5.5p | %-15.50t | %-25.50c{1} | %m%n
10 |
11 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | OvSDB Client Library
2 |
3 | Copyright (c) 2018 VMware, Inc. All Rights Reserved.
4 |
5 | This product is licensed to you under the BSD-2 license (the "License"). You
6 | may not use this product except in compliance with the BSD-2 License.
7 |
8 | This product may include a number of subcomponents with separate copyright
9 | notices and license terms. Your use of these subcomponents is subject to the
10 | terms and conditions of the subcomponent's license, as noted in the LICENSE
11 | file.
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: true
2 |
3 | language: java
4 |
5 | addons:
6 | apt:
7 | packages:
8 | - net-tools
9 |
10 | jdk: oraclejdk8
11 |
12 | env:
13 | - DOCKER_HOST=tcp://127.0.0.1:2375
14 |
15 | services:
16 | - docker
17 |
18 | before_install:
19 | - docker pull hechaol/ovs:2.9.0
20 | - export HOST_IP=$(/sbin/ifconfig docker0 | grep 'inet addr:' | cut -d':' -f2| cut -d' ' -f1)
21 |
22 | script:
23 | - mvn clean verify -Dhost.ip=$HOST_IP
24 |
25 | after_success:
26 | - mvn clean cobertura:cobertura-integration-test coveralls:report -Dhost.ip=$HOST_IP
27 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | /**
16 | * This package includes implementations of operations.
17 | *
18 | * @see OVSDB Management Protocol 5.2
19 | */
20 |
21 | package com.vmware.ovsdb.protocol.operation;
22 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/schema/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | /**
16 | * This package includes implementations of schema format.
17 | *
18 | * @see OVSDB Management Protocol Section
19 | * 3.2
20 | */
21 |
22 | package com.vmware.ovsdb.protocol.schema;
23 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/methods/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | /**
16 | * This package includes implementations of notations used in RPC methods.
17 | *
18 | * @see OVSDB Management Protocol 4.1
19 | */
20 |
21 | package com.vmware.ovsdb.protocol.methods;
22 |
--------------------------------------------------------------------------------
/json-rpc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | ovsdb-client-library
7 | com.vmware.ovsdb
8 | 1.0.1
9 |
10 | 4.0.0
11 |
12 | JSON RPC 1.0
13 | json-rpc
14 |
15 |
16 |
17 | com.fasterxml.jackson.core
18 | jackson-core
19 |
20 |
21 | com.fasterxml.jackson.core
22 | jackson-databind
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | /**
16 | * This package includes implementations of notations used in transaction operations.
17 | *
18 | * @see OVSDB Management Protocol 5.1
19 | */
20 |
21 | package com.vmware.ovsdb.protocol.operation.notation;
22 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/exception/OvsdbClientException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.exception;
16 |
17 | public class OvsdbClientException extends Exception {
18 |
19 | public OvsdbClientException(String message) {
20 | super(message);
21 | }
22 |
23 | public OvsdbClientException(Throwable cause) {
24 | super(cause);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/callback/LockCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.callback;
16 |
17 | /**
18 | * Callback for "lock" operation.
19 | */
20 | public interface LockCallback {
21 |
22 | /**
23 | * Called when the lock is acquired.
24 | */
25 | void locked();
26 |
27 |
28 | /**
29 | * Called when the lock is stolen.
30 | */
31 | void stolen();
32 | }
33 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcDuplicateIdException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that a RPC call id duplicate.
19 | */
20 | public class JsonRpcDuplicateIdException extends JsonRpcException {
21 |
22 | public JsonRpcDuplicateIdException(String message) {
23 | super(message);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcConnectionClosedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that a RPC connection is closed.
19 | */
20 | public class JsonRpcConnectionClosedException extends JsonRpcException {
21 |
22 | public JsonRpcConnectionClosedException(String message) {
23 | super(message);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcInvalidResponseException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that a RPC response is invalid.
19 | */
20 | public class JsonRpcInvalidResponseException extends JsonRpcException {
21 |
22 | public JsonRpcInvalidResponseException(String message, Throwable cause) {
23 | super(message, cause);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcResultTypeMismatchException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that there the RPC method result type does not match the expected type.
19 | */
20 | public class JsonRpcResultTypeMismatchException extends JsonRpcException {
21 |
22 | public JsonRpcResultTypeMismatchException(String message, Throwable cause) {
23 | super(message, cause);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/testutils/HardwareGatewayConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.testutils;
16 |
17 | public class HardwareGatewayConstants {
18 |
19 | public static final String HARDWARE_VTEP = "hardware_vtep";
20 |
21 | public static final String LOGICAL_SWITCH = "Logical_Switch";
22 |
23 | public static final String PHYSICAL_LOCATOR = "Physical_Locator";
24 |
25 | public static final String UCAST_MACS_REMOTE = "Ucast_Macs_Remote";
26 | }
27 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/schema/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.schema;
16 |
17 | public class Constants {
18 |
19 | public static final String JSON_INTEGER = "\"integer\"";
20 |
21 | public static final String JSON_REAL = "\"real\"";
22 |
23 | public static final String JSON_BOOLEAN = "\"boolean\"";
24 |
25 | public static final String JSON_STRING = "\"string\"";
26 |
27 | public static final String JSON_UUID = "\"uuid\"";
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/callback/MonitorCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.callback;
16 |
17 | import com.vmware.ovsdb.protocol.methods.TableUpdates;
18 |
19 | /**
20 | * Callback for "monitor" operation.
21 | */
22 | public interface MonitorCallback {
23 |
24 | /**
25 | * Called when there are updates for the corresponding monitor request.
26 | *
27 | * @param tableUpdates updates from the monitored tables
28 | */
29 | void update(TableUpdates tableUpdates);
30 | }
31 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/util/JsonRpcConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.util;
16 |
17 | /**
18 | * Constants used in JSON-RPC protocol.
19 | */
20 | public class JsonRpcConstant {
21 |
22 | public static final String METHOD = "method";
23 |
24 | public static final String PARAMS = "params";
25 |
26 | public static final String ID = "id";
27 |
28 | public static final String RESULT = "result";
29 |
30 | public static final String ERROR = "error";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcTransportException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that there is something wrong with the JSON-RPC transporter.
19 | */
20 | public class JsonRpcTransportException extends JsonRpcException {
21 |
22 | public JsonRpcTransportException(String message) {
23 | super(message);
24 | }
25 |
26 | public JsonRpcTransportException(Throwable cause) {
27 | super(cause);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/exception/JsonRpcException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.exception;
16 |
17 | /**
18 | * Thrown to indicate that there is something wrong with this JSON-RPC client / server.
19 | */
20 | public class JsonRpcException extends Exception {
21 |
22 | public JsonRpcException(String message) {
23 | super(message);
24 | }
25 |
26 | public JsonRpcException(Throwable cause) {
27 | super(cause);
28 | }
29 |
30 | public JsonRpcException(String message, Throwable cause) {
31 | super(message, cause);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/testutils/TestConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.testutils;
16 |
17 | public class TestConstants {
18 |
19 | public static final String OVS_DOCKER_IMAGE = "hechaol/ovs:2.9.0";
20 |
21 | public static final int VERIFY_TIMEOUT_MILLIS = 5 * 1000; // 5 seconds
22 |
23 | public static final int TEST_TIMEOUT_MILLIS = 60 * 1000; // 1 minutes
24 |
25 | public static String HOST_IP = System.getProperty("host.ip");
26 |
27 | public static final String LOCAL_HOST = "127.0.0.1";
28 |
29 | public static final int OVSDB_PORT = 6640;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/operation/AbortTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 |
20 | import com.fasterxml.jackson.core.JsonProcessingException;
21 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
22 | import org.junit.Test;
23 |
24 | public class AbortTest {
25 |
26 | @Test
27 | public void testSerialization() throws JsonProcessingException {
28 | Abort abort = new Abort();
29 | String expectedResult = "{\"op\":\"abort\"}";
30 | assertEquals(expectedResult, JsonUtil.serialize(abort));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/schema/BooleanBaseType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.schema;
16 |
17 | import com.vmware.ovsdb.protocol.operation.notation.Value;
18 |
19 | /**
20 | *
21 | * {@literal
22 | * Represent a with a boolean as it's type.
23 | * }
24 | *
25 | *
26 | * @see BaseType
27 | * @see AtomicType
28 | */
29 | public class BooleanBaseType extends BaseType {
30 |
31 | public BooleanBaseType() {
32 | super(AtomicType.BOOLEAN);
33 | }
34 |
35 | public BooleanBaseType(Value enums) {
36 | super(AtomicType.BOOLEAN, enums);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/schema/BaseTypeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.schema;
16 |
17 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
18 | import org.junit.Test;
19 |
20 | import java.io.IOException;
21 |
22 | public class BaseTypeTest {
23 |
24 | @Test(expected = IOException.class)
25 | public void testInvalidType() throws IOException {
26 | JsonUtil.deserialize("{\"type\": \"double\"}", BaseType.class);
27 | }
28 |
29 | @Test(expected = IOException.class)
30 | public void testMissingType() throws IOException {
31 | JsonUtil.deserialize("{\"minInteger\": 0, \"maxInteger\":1}", BaseType.class);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/result/EmptyResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.result;
16 |
17 | /**
18 | * This is used for operations who has an empty result. For example, "wait", "commit", "abort",
19 | * "comment" and "assert".
20 | */
21 | public class EmptyResult extends OperationResult {
22 |
23 | @Override
24 | public int hashCode() {
25 | return 0;
26 | }
27 |
28 | @Override
29 | public boolean equals(Object other) {
30 | return this == other || other instanceof EmptyResult;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return getClass().getSimpleName() + " []";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/json-rpc/src/test/java/com/vmware/ovsdb/jsonrpc/v1/util/TestUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.util;
16 |
17 | import com.fasterxml.jackson.databind.JsonNode;
18 | import com.vmware.ovsdb.jsonrpc.v1.model.JsonRpcV1Request;
19 | import com.vmware.ovsdb.jsonrpc.v1.model.JsonRpcV1Response;
20 |
21 | public class TestUtil {
22 |
23 | public static JsonNode getRequestNode(String id, String method, Object... params) {
24 | return JsonUtil.toJsonNode(new JsonRpcV1Request(id, method, params));
25 | }
26 |
27 | public static JsonNode getResponseNode(String id, Object result, String error) {
28 | return JsonUtil.toJsonNode(new JsonRpcV1Response(result, error, id));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/Value.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.notation;
16 |
17 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
18 | import com.vmware.ovsdb.protocol.operation.notation.deserializer.ValueDeserializer;
19 |
20 | /**
21 | *
22 | * {@literal
23 | *
24 | * A JSON value that represents the value of a column in a table row,
25 | * one of , , or
28 | *
29 | * @see Atom
30 | * @see Set
31 | * @see Map
32 | */
33 | @JsonDeserialize(using = ValueDeserializer.class)
34 | public abstract class Value {
35 |
36 | protected Value() {
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/netty/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.netty;
16 |
17 | import io.netty.channel.ChannelDuplexHandler;
18 | import io.netty.channel.ChannelHandlerContext;
19 | import org.slf4j.Logger;
20 | import org.slf4j.LoggerFactory;
21 |
22 | import java.lang.invoke.MethodHandles;
23 |
24 | class ExceptionHandler extends ChannelDuplexHandler {
25 |
26 | private static final Logger LOGGER = LoggerFactory
27 | .getLogger(MethodHandles.lookup().lookupClass());
28 |
29 | @Override
30 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
31 | LOGGER.error("Channel " + ctx.channel() + " encountered exception. Closing.", cause);
32 | ctx.close();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/util/PropertyManagerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.util;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 | import org.junit.Test;
20 |
21 | public class PropertyManagerTest {
22 |
23 | @Test
24 | public void testBasic() {
25 | // A valid property should return the value in the property file
26 | assertEquals(10, PropertyManager.getIntProperty("rpc.timeout.sec", 42));
27 | // A nonexistent property should return default value
28 | assertEquals(42, PropertyManager.getLongProperty("non.existent.prop", 42));
29 | // An invalid integer property should return default value
30 | assertEquals(42, PropertyManager.getLongProperty("invalid.int", 42));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/Mutator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.notation;
16 |
17 | import com.fasterxml.jackson.annotation.JsonValue;
18 |
19 | /**
20 | *
21 | * {@literal
22 | *
23 | * One of "+=", "-=", "*=", "/=", "%=", "insert", or "delete".
24 | * }
25 | *
26 | */
27 | public enum Mutator {
28 | SUM("+="),
29 | DIFFERENCE("-="),
30 | PRODUCT("*="),
31 | QUOTIENT("/="),
32 | REMINDER("%="),
33 | INSERT("insert"),
34 | DELETE("delete");
35 |
36 | private String name;
37 |
38 | Mutator(String name) {
39 | this.name = name;
40 | }
41 |
42 | @JsonValue
43 | public String toString() {
44 | return name;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/annotation/JsonRpcServiceMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.annotation;
16 |
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | /**
23 | * Annotate the RPC handler methods.
24 | */
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target(ElementType.METHOD)
27 | public @interface JsonRpcServiceMethod {
28 |
29 | /**
30 | * JSON-RPC methods name. The value is the RPC method name. By default the value is empty and the
31 | * Java method name is used.
32 | *
33 | * @return JSON-RPC method name
34 | */
35 | String value() default "";
36 | }
37 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/spi/JsonRpcTransporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.spi;
16 |
17 | import com.fasterxml.jackson.databind.JsonNode;
18 | import com.vmware.ovsdb.jsonrpc.v1.exception.JsonRpcTransportException;
19 |
20 | /**
21 | * The underlying transport com.vmware.ovsdb.protocol for JSON-RPC. The implementation must be
22 | * thread-safe.
23 | */
24 | public interface JsonRpcTransporter {
25 |
26 | /**
27 | * Send a JSON data to peer.
28 | *
29 | * @param data JSON data to send
30 | * @throws JsonRpcTransportException if fail to send the data
31 | */
32 | void send(JsonNode data) throws JsonRpcTransportException;
33 |
34 | /**
35 | * Close the transporter.
36 | */
37 | void close();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/schema/AtomicType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.schema;
16 |
17 | import com.fasterxml.jackson.annotation.JsonValue;
18 |
19 | /**
20 | *
21 | * {@literal
22 | *
23 | * One of the strings "integer", "real", "boolean", "string", or
24 | * "uuid", representing the specified scalar type.
25 | * }
26 | *
27 | */
28 | public enum AtomicType {
29 | INTEGER("integer"),
30 | REAL("real"),
31 | BOOLEAN("boolean"),
32 | STRING("string"),
33 | UUID("uuid");
34 |
35 | private String atomicType;
36 |
37 | AtomicType(String atomicType) {
38 | this.atomicType = atomicType;
39 | }
40 |
41 | @JsonValue
42 | public String toString() {
43 | return atomicType;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/callback/ConnectionCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.callback;
16 |
17 | import com.vmware.ovsdb.service.OvsdbClient;
18 |
19 | /**
20 | * Callback that is called when an OVSDB server is connected / disconnected to the manager.
21 | */
22 | public interface ConnectionCallback {
23 |
24 | /**
25 | * Called when an OVSDB server is connected to the manager.
26 | *
27 | * @param ovsdbClient the {@link OvsdbClient} that can be used to communicate with the server
28 | */
29 | void connected(OvsdbClient ovsdbClient);
30 |
31 | /**
32 | * Called when an OVSDB server is disconnected from the manager.
33 | *
34 | * @param ovsdbClient the {@link OvsdbClient} that is used to communicate with the server
35 | */
36 | void disconnected(OvsdbClient ovsdbClient);
37 | }
38 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/Abort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | import static com.vmware.ovsdb.protocol.util.OvsdbConstant.ABORT;
18 |
19 | /**
20 | *
21 | * {@literal
22 | * The "abort" object contains the following member:
23 | *
24 | * "op": "abort" required
25 | *
26 | * There is no corresponding result object (the operation never
27 | * succeeds).
28 | *
29 | * The operation aborts the entire transaction with an error. This may
30 | * be useful for testing.
31 | *
32 | * The error that will be returned is:
33 | *
34 | * "error": "aborted"
35 | * This operation always fails with this error.
36 | * }
37 | *
38 | */
39 | public class Abort extends Operation {
40 |
41 | protected Abort() {
42 | super(ABORT);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/operation/AssertTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 |
20 | import com.fasterxml.jackson.core.JsonProcessingException;
21 | import com.google.common.testing.EqualsTester;
22 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
23 | import org.junit.Test;
24 |
25 | public class AssertTest {
26 |
27 | @Test
28 | public void testSerialization() throws JsonProcessingException {
29 | Assert assrt = new Assert("myLock");
30 | String expectedResult = "{\"op\":\"assert\",\"lock\":\"myLock\"}";
31 | assertEquals(expectedResult, JsonUtil.serialize(assrt));
32 | }
33 |
34 | @Test
35 | public void testEquals() {
36 | new EqualsTester().addEqualityGroup(new Assert("lock"), new Assert("lock")).testEquals();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/serializer/RowSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.notation.serializer;
16 |
17 | import com.fasterxml.jackson.core.JsonGenerator;
18 | import com.fasterxml.jackson.databind.SerializerProvider;
19 | import com.fasterxml.jackson.databind.ser.std.StdSerializer;
20 | import com.vmware.ovsdb.protocol.operation.notation.Row;
21 |
22 | import java.io.IOException;
23 |
24 | public class RowSerializer extends StdSerializer {
25 |
26 | public RowSerializer() {
27 | this(null);
28 | }
29 |
30 | protected RowSerializer(Class klass) {
31 | super(klass);
32 | }
33 |
34 | @Override
35 | public void serialize(
36 | Row row, JsonGenerator jgen, SerializerProvider provider
37 | ) throws IOException {
38 | jgen.writeObject(row.getColumns());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/serializer/AtomSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.notation.serializer;
16 |
17 | import com.fasterxml.jackson.core.JsonGenerator;
18 | import com.fasterxml.jackson.databind.SerializerProvider;
19 | import com.fasterxml.jackson.databind.ser.std.StdSerializer;
20 | import com.vmware.ovsdb.protocol.operation.notation.Atom;
21 |
22 | import java.io.IOException;
23 |
24 | public class AtomSerializer extends StdSerializer {
25 |
26 | public AtomSerializer() {
27 | this(null);
28 | }
29 |
30 | protected AtomSerializer(Class klass) {
31 | super(klass);
32 | }
33 |
34 | @Override
35 | public void serialize(
36 | Atom atom, JsonGenerator jgen, SerializerProvider provider
37 | ) throws IOException {
38 | jgen.writeObject(atom.getValue());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/operation/result/UpdateResultTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.result;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 | import com.google.common.testing.EqualsTester;
20 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
21 | import org.junit.Test;
22 |
23 | public class UpdateResultTest {
24 |
25 | @Test
26 | public void testDeserialization() {
27 | String jsonString = "{\"count\":2}";
28 |
29 | UpdateResult expectedResult = new UpdateResult(2);
30 |
31 | assertEquals(
32 | expectedResult, JsonUtil.deserializeNoException(jsonString, OperationResult.class)
33 | );
34 | }
35 |
36 | @Test
37 | public void testEquals() {
38 | new EqualsTester()
39 | .addEqualityGroup(new UpdateResult(42), new UpdateResult(42))
40 | .testEquals();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/json-rpc/src/main/java/com/vmware/ovsdb/jsonrpc/v1/service/JsonRpcV1Server.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.jsonrpc.v1.service;
16 |
17 | import com.fasterxml.jackson.databind.JsonNode;
18 | import com.vmware.ovsdb.jsonrpc.v1.exception.JsonRpcException;
19 |
20 | /**
21 | * Interface for a JSON-RPC 1.0 server that handles RPC requests from the clients.
22 | */
23 | public interface JsonRpcV1Server {
24 |
25 | /**
26 | * Handle the request from the client.
27 | *
28 | * @param requestNode the request {@link JsonNode}
29 | * @throws JsonRpcException if fail to handle the request
30 | */
31 | void handleRequest(JsonNode requestNode) throws JsonRpcException;
32 |
33 | /**
34 | * Shutdown this server. After it is called, no other methods shall be called on this server any
35 | * more. The request that is being handled may be affected.
36 | */
37 | void shutdown();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/operation/CommentTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 |
20 | import com.fasterxml.jackson.core.JsonProcessingException;
21 | import com.google.common.testing.EqualsTester;
22 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
23 | import org.junit.Test;
24 |
25 | public class CommentTest {
26 |
27 | @Test
28 | public void testSerialization() throws JsonProcessingException {
29 | Comment comment = new Comment("Transaction from me");
30 | String expectedResult
31 | = "{\"op\":\"comment\",\"comment\":\"Transaction from me\"}";
32 |
33 | assertEquals(expectedResult, JsonUtil.serialize(comment));
34 | }
35 |
36 | @Test
37 | public void testEquals() {
38 | new EqualsTester()
39 | .addEqualityGroup(new Comment("comment"), new Comment("comment"))
40 | .testEquals();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ovsdb-client/src/test/java/com/vmware/ovsdb/protocol/operation/CommitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 |
20 | import com.fasterxml.jackson.core.JsonProcessingException;
21 | import com.google.common.testing.EqualsTester;
22 | import com.vmware.ovsdb.jsonrpc.v1.util.JsonUtil;
23 | import org.junit.Test;
24 |
25 | public class CommitTest {
26 |
27 | @Test
28 | public void testSerialization() throws JsonProcessingException {
29 | Commit commit = new Commit(true);
30 | String expectedResult = "{\"op\":\"commit\",\"durable\":true}";
31 |
32 | assertEquals(expectedResult, JsonUtil.serialize(commit));
33 | }
34 |
35 | @Test
36 | public void testEquals() {
37 | new EqualsTester()
38 | .addEqualityGroup(new Commit(false), new Commit(false))
39 | .addEqualityGroup(new Commit(true), new Commit(true))
40 | .testEquals();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/methods/serializer/MonitorRequestsSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.methods.serializer;
16 |
17 | import com.fasterxml.jackson.core.JsonGenerator;
18 | import com.fasterxml.jackson.databind.SerializerProvider;
19 | import com.fasterxml.jackson.databind.ser.std.StdSerializer;
20 | import com.vmware.ovsdb.protocol.methods.MonitorRequests;
21 |
22 | import java.io.IOException;
23 |
24 | public class MonitorRequestsSerializer extends StdSerializer {
25 |
26 | public MonitorRequestsSerializer() {
27 | this(null);
28 | }
29 |
30 | protected MonitorRequestsSerializer(Class klass) {
31 | super(klass);
32 | }
33 |
34 | @Override
35 | public void serialize(
36 | MonitorRequests monitorRequests, JsonGenerator jgen,
37 | SerializerProvider provider
38 | ) throws IOException {
39 | jgen.writeObject(monitorRequests.getMonitorRequests());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/Operation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation;
16 |
17 | /**
18 | * The operations that may be performed as part of a "transact" RPC request (see Section 4.1.3) are
19 | * described in the following subsections. Each of these operations is a JSON object that may be
20 | * included as one of the elements of the "params" array that is one of the elements of the
21 | * "transact" request. The details of each object, its semantics, results, and possible errors are
22 | * described below.
23 | *
24 | * @see Insert
25 | * @see Select
26 | * @see Update
27 | * @see Mutate
28 | * @see Delete
29 | * @see Wait
30 | * @see Commit
31 | * @see Abort
32 | * @see Comment
33 | * @see Assert
34 | */
35 | public abstract class Operation {
36 |
37 | private final String op;
38 |
39 | protected Operation(String op) {
40 | this.op = op;
41 | }
42 |
43 | public String getOp() {
44 | return op;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | OvSDB Client Library
2 |
3 | Copyright (c) 2018 VMware, Inc. All rights reserved.
4 |
5 | The BSD-2 license (the License) set forth below applies to all parts of the
6 | OvSDB Client Library project. You may not use this file except in compliance
7 | with the License.
8 |
9 | BSD-2 License
10 |
11 | Redistribution and use in source and binary forms, with or without modification,
12 | are permitted provided that the following conditions are met:
13 | Redistributions of source code must retain the above copyright notice, this
14 | list of conditions and the following disclaimer.
15 | Redistributions in binary form must reproduce the above copyright notice,
16 | this list of conditions and the following disclaimer in the documentation and/or
17 | other materials provided with the distribution.
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/ovsdb-client/src/main/java/com/vmware/ovsdb/protocol/operation/notation/deserializer/RowDeserializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3 | *
4 | * This product is licensed to you under the BSD-2 license (the "License").
5 | * You may not use this product except in compliance with the BSD-2 License.
6 | *
7 | * This product may include a number of subcomponents with separate copyright
8 | * notices and license terms. Your use of these subcomponents is subject to the
9 | * terms and conditions of the subcomponent's license, as noted in the LICENSE
10 | * file.
11 | *
12 | * SPDX-License-Identifier: BSD-2-Clause
13 | */
14 |
15 | package com.vmware.ovsdb.protocol.operation.notation.deserializer;
16 |
17 | import com.fasterxml.jackson.core.JsonParser;
18 | import com.fasterxml.jackson.core.type.TypeReference;
19 | import com.fasterxml.jackson.databind.DeserializationContext;
20 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
21 | import com.vmware.ovsdb.protocol.operation.notation.Row;
22 | import com.vmware.ovsdb.protocol.operation.notation.Value;
23 |
24 | import java.io.IOException;
25 | import java.util.Map;
26 |
27 | public class RowDeserializer extends StdDeserializer {
28 |
29 | protected RowDeserializer() {
30 | this(null);
31 | }
32 |
33 | protected RowDeserializer(Class> vc) {
34 | super(vc);
35 | }
36 |
37 | @Override
38 | public Row deserialize(
39 | JsonParser jp, DeserializationContext ctxt
40 | ) throws IOException {
41 | TypeReference