I think this patch should be folded into the last one.

On Sat, Jan 16, 2016 at 12:16 AM, Liran Schour <lir...@il.ibm.com> wrote:

> Replace monitor2 with monitor_cond with empty condition.
>
> Signed-off-by: Liran Schour <lir...@il.ibm.com>
> ---
>  lib/ovsdb-idl.c        | 28 ++++++++++++++--------------
>  ovsdb/jsonrpc-server.c | 14 +++++++-------
>  ovsdb/jsonrpc-server.h |  2 +-
>  ovsdb/ovsdb-client.c   | 27 ++++++---------------------
>  ovsdb/ovsdb-server.c   | 20 +++++++++++---------
>  tests/ovs-vswitchd.at  |  8 ++++----
>  tests/ovsdb-idl.at     | 10 +++++-----
>  7 files changed, 48 insertions(+), 61 deletions(-)
>
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 7e84138..18d4b8b 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -79,8 +79,8 @@ enum ovsdb_idl_state {
>      IDL_S_SCHEMA_REQUESTED,
>      IDL_S_MONITOR_REQUESTED,
>      IDL_S_MONITORING,
> -    IDL_S_MONITOR2_REQUESTED,
> -    IDL_S_MONITORING2
> +    IDL_S_MONITOR_COND_REQUESTED,
> +    IDL_S_MONITORING_COND
>  };
>
>  struct ovsdb_idl {
> @@ -153,7 +153,7 @@ static struct vlog_rate_limit semantic_rl =
> VLOG_RATE_LIMIT_INIT(1, 5);
>  static void ovsdb_idl_clear(struct ovsdb_idl *);
>  static void ovsdb_idl_send_schema_request(struct ovsdb_idl *);
>  static void ovsdb_idl_send_monitor_request(struct ovsdb_idl *);
> -static void ovsdb_idl_send_monitor2_request(struct ovsdb_idl *);
> +static void ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *);
>  static void ovsdb_idl_parse_update(struct ovsdb_idl *, const struct json
> *,
>                                     enum ovsdb_update_version);
>  static struct ovsdb_error *ovsdb_idl_parse_update__(struct ovsdb_idl *,
> @@ -392,20 +392,20 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>              case IDL_S_SCHEMA_REQUESTED:
>                  /* Reply to our "get_schema" request. */
>                  idl->schema = json_clone(msg->result);
> -                ovsdb_idl_send_monitor2_request(idl);
> -                idl->state = IDL_S_MONITOR2_REQUESTED;
> +                ovsdb_idl_send_monitor_cond_request(idl);
> +                idl->state = IDL_S_MONITOR_COND_REQUESTED;
>                  break;
>
>              case IDL_S_MONITOR_REQUESTED:
> -            case IDL_S_MONITOR2_REQUESTED:
> -                /* Reply to our "monitor" or "monitor2" request. */
> +            case IDL_S_MONITOR_COND_REQUESTED:
> +                /* Reply to our "monitor" or "monitor_cond" request. */
>                  idl->change_seqno++;
>                  ovsdb_idl_clear(idl);
>                  if (idl->state == IDL_S_MONITOR_REQUESTED) {
>                      idl->state = IDL_S_MONITORING;
>                      ovsdb_idl_parse_update(idl, msg->result,
> OVSDB_UPDATE);
> -                } else { /* IDL_S_MONITOR2_REQUESTED. */
> -                    idl->state = IDL_S_MONITORING2;
> +                } else { /* IDL_S_MONITOR_COND_REQUESTED. */
> +                    idl->state = IDL_S_MONITORING_COND;
>                      ovsdb_idl_parse_update(idl, msg->result,
> OVSDB_UPDATE2);
>                  }
>
> @@ -416,7 +416,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>                  break;
>
>              case IDL_S_MONITORING:
> -            case IDL_S_MONITORING2:
> +            case IDL_S_MONITORING_COND:
>              default:
>                  OVS_NOT_REACHED();
>              }
> @@ -442,7 +442,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>              /* Someone else stole our lock. */
>              ovsdb_idl_parse_lock_notify(idl, msg->params, false);
>          } else if (msg->type == JSONRPC_ERROR
> -                   && idl->state == IDL_S_MONITOR2_REQUESTED
> +                   && idl->state == IDL_S_MONITOR_COND_REQUESTED
>                     && idl->request_id
>                     && json_equal(idl->request_id, msg->id)) {
>              if (msg->error && !strcmp(json_string(msg->error),
> @@ -1012,9 +1012,9 @@ log_parse_update_error(struct ovsdb_error *error)
>  }
>
>  static void
> -ovsdb_idl_send_monitor2_request(struct ovsdb_idl *idl)
> +ovsdb_idl_send_monitor_cond_request(struct ovsdb_idl *idl)
>  {
> -    ovsdb_idl_send_monitor_request__(idl, "monitor2");
> +    ovsdb_idl_send_monitor_request__(idl, "monitor_cond");
>  }
>
>  static void
> @@ -3033,7 +3033,7 @@ ovsdb_idl_update_has_lock(struct ovsdb_idl *idl,
> bool new_has_lock)
>  {
>      if (new_has_lock && !idl->has_lock) {
>          if (idl->state == IDL_S_MONITORING ||
> -            idl->state == IDL_S_MONITORING2) {
> +            idl->state == IDL_S_MONITORING_COND) {
>              idl->change_seqno++;
>          } else {
>              /* We're setting up a session, so don't signal that the
> database
> diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
> index e4500da..3439f40 100644
> --- a/ovsdb/jsonrpc-server.c
> +++ b/ovsdb/jsonrpc-server.c
> @@ -46,9 +46,9 @@ VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server);
>  struct ovsdb_jsonrpc_remote;
>  struct ovsdb_jsonrpc_session;
>
> -/* Set false to defeature monitor2, causing jsonrpc to respond to monitor2
> - * method with an error.  */
> -static bool monitor2_enable__ = true;
> +/* Set false to defeature monitor_cond, causing jsonrpc to respond to
> + * monitor_cond method with an error.  */
> +static bool monitor_cond_enable__ = true;
>
>  /* Message rate-limiting. */
>  static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
> @@ -850,8 +850,8 @@ ovsdb_jsonrpc_session_got_request(struct
> ovsdb_jsonrpc_session *s,
>              reply = execute_transaction(s, db, request);
>          }
>      } else if (!strcmp(request->method, "monitor") ||
> -               (monitor2_enable__ && !strcmp(request->method,
> "monitor2")) ||
> -               !strcmp(request->method, "monitor_cond")) {
> +               (monitor_cond_enable__ && !strcmp(request->method,
> +                                                 "monitor_cond"))) {
>          struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, &reply);
>          if (!reply) {
>              int l = strlen(request->method) - strlen("monitor");
> @@ -1409,8 +1409,8 @@ ovsdb_jsonrpc_monitor_flush_all(struct
> ovsdb_jsonrpc_session *s)
>  }
>
>  void
> -ovsdb_jsonrpc_disable_monitor2(void)
> +ovsdb_jsonrpc_disable_monitor_cond(void)
>  {
>      /* Once disabled, it is not possible to re-enable it. */
> -    monitor2_enable__ = false;
> +    monitor_cond_enable__ = false;
>  }
> diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h
> index 7a0bd31..ea50ff6 100644
> --- a/ovsdb/jsonrpc-server.h
> +++ b/ovsdb/jsonrpc-server.h
> @@ -71,6 +71,6 @@ void ovsdb_jsonrpc_server_get_memory_usage(const struct
> ovsdb_jsonrpc_server *,
>
>  struct ovsdb_jsonrpc_monitor;
>  void ovsdb_jsonrpc_monitor_destroy(struct ovsdb_jsonrpc_monitor *);
> -void ovsdb_jsonrpc_disable_monitor2(void);
> +void ovsdb_jsonrpc_disable_monitor_cond(void);
>
>  #endif /* ovsdb/jsonrpc-server.h */
> diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
> index e48677e..ebcaa9a 100644
> --- a/ovsdb/ovsdb-client.c
> +++ b/ovsdb/ovsdb-client.c
> @@ -260,9 +260,6 @@ usage(void)
>             "\n  monitor [SERVER] [DATABASE] ALL\n"
>             "    monitor all changes to all columns in all tables\n"
>             "    in DATBASE on SERVER.\n"
> -           "\n  monitor2 [SERVER] [DATABASE] ALL\n"
> -           "    same usage as monitor, but uses \"monitor2\" method over"
> -           "    the wire.\n"
>             "\n  monitor-cond [SERVER] [DATABASE] TABLE CONDITION
> [COLUMN,..]\n"
>             "    conditionally monitor contents of COLUMNS in TABLE in\n"
>             "    DATABASE on SERVER.\n"
> @@ -914,7 +911,7 @@ destroy_monitored_table(struct monitored_table *mts,
> size_t n)
>
>  static void
>  do_monitor__(struct jsonrpc *rpc, const char *database,
> -             enum ovsdb_monitor_version version, const bool conditional,
> +             enum ovsdb_monitor_version version,
>               int argc, char *argv[])
>  {
>      const char *server = jsonrpc_get_name(rpc);
> @@ -925,6 +922,7 @@ do_monitor__(struct jsonrpc *rpc, const char *database,
>      struct json *monitor, *monitor_requests, *request_id;
>      bool exiting = false;
>      bool blocked = false;
> +    bool conditional = version == OVSDB_MONITOR_V2 ? true : false;
>
>      struct monitored_table *mts;
>      size_t n_mts, allocated_mts;
> @@ -985,13 +983,8 @@ do_monitor__(struct jsonrpc *rpc, const char
> *database,
>
>      monitor = json_array_create_3(json_string_create(database),
>                                    json_null_create(), monitor_requests);
> -    const char *method;
> -    if (!conditional) {
> -        method = version == OVSDB_MONITOR_V2 ? "monitor2"
> -                                             : "monitor";
> -    } else {
> -        method = "monitor_cond";
> -    }
> +    const char *method = version == OVSDB_MONITOR_V2 ?
> +                                         "monitor_cond" : "monitor";
>
>      request = jsonrpc_create_request(method, monitor, NULL);
>      request_id = json_clone(request->id);
> @@ -1074,21 +1067,14 @@ static void
>  do_monitor(struct jsonrpc *rpc, const char *database,
>             int argc, char *argv[])
>  {
> -    do_monitor__(rpc, database, OVSDB_MONITOR_V1, false, argc, argv);
> -}
> -
> -static void
> -do_monitor2(struct jsonrpc *rpc, const char *database,
> -           int argc, char *argv[])
> -{
> -    do_monitor__(rpc, database, OVSDB_MONITOR_V2, false, argc, argv);
> +    do_monitor__(rpc, database, OVSDB_MONITOR_V1, argc, argv);
>  }
>
>  static void
>  do_monitor_cond(struct jsonrpc *rpc, const char *database,
>                  int argc, char *argv[])
>  {
> -    do_monitor__(rpc, database, OVSDB_MONITOR_V2, true, argc, argv);
> +    do_monitor__(rpc, database, OVSDB_MONITOR_V2, argc, argv);
>  }
>
>  struct dump_table_aux {
> @@ -1361,7 +1347,6 @@ static const struct ovsdb_client_command
> all_commands[] = {
>      { "list-columns",       NEED_DATABASE, 0, 1,       do_list_columns },
>      { "transact",           NEED_RPC,      1, 1,       do_transact },
>      { "monitor",            NEED_DATABASE, 1, INT_MAX, do_monitor },
> -    { "monitor2",           NEED_DATABASE, 1, INT_MAX, do_monitor2 },
>      { "monitor-cond",       NEED_DATABASE, 2, 3,       do_monitor_cond },
>      { "dump",               NEED_DATABASE, 0, INT_MAX, do_dump },
>      { "help",               NEED_NONE,     0, INT_MAX, do_help },
> diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
> index 231ba2f..343fd59 100644
> --- a/ovsdb/ovsdb-server.c
> +++ b/ovsdb/ovsdb-server.c
> @@ -79,7 +79,7 @@ static unixctl_cb_func ovsdb_server_compact;
>  static unixctl_cb_func ovsdb_server_reconnect;
>  static unixctl_cb_func ovsdb_server_perf_counters_clear;
>  static unixctl_cb_func ovsdb_server_perf_counters_show;
> -static unixctl_cb_func ovsdb_server_disable_monitor2;
> +static unixctl_cb_func ovsdb_server_disable_monitor_cond;
>
>  struct server_config {
>      struct sset *remotes;
> @@ -332,9 +332,9 @@ main(int argc, char *argv[])
>                               ovsdb_server_perf_counters_clear, NULL);
>
>      /* Simulate the behavior of OVS release prior to version 2.5 that
> -     * does not support the monitor2 method.  */
> -    unixctl_command_register("ovsdb-server/disable-monitor2", "", 0, 0,
> -                             ovsdb_server_disable_monitor2, jsonrpc);
> +     * does not support the monitor_cond method.  */
> +    unixctl_command_register("ovsdb-server/disable-monitor-cond", "", 0,
> 0,
> +                             ovsdb_server_disable_monitor_cond, jsonrpc);
>
>      main_loop(jsonrpc, &all_dbs, unixctl, &remotes, run_process,
> &exiting);
>
> @@ -1059,16 +1059,18 @@ ovsdb_server_perf_counters_clear(struct
> unixctl_conn *conn, int argc OVS_UNUSED,
>      unixctl_command_reply(conn, NULL);
>  }
>
> -/* "ovsdb-server/disable-monitor2": makes ovsdb-server drop all of its
> +/* "ovsdb-server/disable-monitor-cond": makes ovsdb-server drop all of its
>   * JSON-RPC connections and reconnect. New sessions will not recognize
> - * the 'monitor2' method.   */
> + * the 'monitor_cond' method.   */
>  static void
> -ovsdb_server_disable_monitor2(struct unixctl_conn *conn, int argc
> OVS_UNUSED,
> -                              const char *argv[] OVS_UNUSED, void
> *jsonrpc_)
> +ovsdb_server_disable_monitor_cond(struct unixctl_conn *conn,
> +                                  int argc OVS_UNUSED,
> +                                  const char *argv[] OVS_UNUSED,
> +                                  void *jsonrpc_)
>  {
>      struct ovsdb_jsonrpc_server *jsonrpc = jsonrpc_;
>
> -    ovsdb_jsonrpc_disable_monitor2();
> +    ovsdb_jsonrpc_disable_monitor_cond();
>      ovsdb_jsonrpc_server_reconnect(jsonrpc);
>      unixctl_command_reply(conn, NULL);
>  }
> diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at
> index 492b944..34c6790 100644
> --- a/tests/ovs-vswitchd.at
> +++ b/tests/ovs-vswitchd.at
> @@ -165,14 +165,14 @@ OVS_VSWITCHD_STOP(["/Not adding Unix domain socket
> controller/d"])
>  AT_CLEANUP
>
>  dnl ----------------------------------------------------------------------
> -dnl OVSDB server before release version 2.5 does not support the monitor2
> +dnl OVSDB server before release version 2.5 does not support the
> monitor_cond
>  dnl method.  This test defeatures the OVSDB server to simulate an older
>  dnl OVSDB server and make sure ovs-vswitchd can still work with it
> -AT_SETUP([ovs-vswitchd -- Compatible with OVSDB server - w/o monitor2)])
> +AT_SETUP([ovs-vswitchd -- Compatible with OVSDB server - w/o
> monitor_cond)])
>  OVS_VSWITCHD_START
>
> -dnl defeature OVSDB server -- no monitor2
> -AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor2])
> +dnl defeature OVSDB server -- no monitor_cond
> +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
>
>  sleep 1
>
> diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
> index ebf82a5..4baac46 100644
> --- a/tests/ovsdb-idl.at
> +++ b/tests/ovsdb-idl.at
> @@ -588,13 +588,13 @@ test-ovsdb|ovsdb_idl|link1 table in idltest database
> lacks l2 column (database n
>  # Check that ovsdb-idl sent on "monitor" request and that it didn't
>  # mention that table or column, and (for paranoia) that it did mention
> another
>  # table and column.
> -AT_CHECK([grep -c '"monitor\|monitor2"' stderr], [0], [1
> +AT_CHECK([grep -c '"monitor\|monitor_cond"' stderr], [0], [1
>  ])
> -AT_CHECK([grep '"monitor\|monitor2"' stderr | grep link2], [1])
> -AT_CHECK([grep '"monitor\|monitor2"' stderr | grep l2], [1])
> -AT_CHECK([grep '"monitor\|monitor2"' stderr | grep -c '"link1"'], [0], [1
> +AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep link2], [1])
> +AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep l2], [1])
> +AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"link1"'],
> [0], [1
>  ])
> -AT_CHECK([grep '"monitor\|monitor2"' stderr | grep -c '"ua"'], [0], [1
> +AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"ua"'], [0], [1
>  ])
>  OVSDB_SERVER_SHUTDOWN
>  AT_CLEANUP
> --
> 2.1.4
>
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to