]> git.proxmox.com Git - mirror_corosync.git/commitdiff
qnetd: move 2nodelms algo files to the right directory
authorChristine Caulfield <ccaulfie@redhat.com>
Fri, 16 Oct 2015 08:42:07 +0000 (09:42 +0100)
committerJan Friesse <jfriesse@redhat.com>
Tue, 28 Jun 2016 11:58:38 +0000 (13:58 +0200)
No, I don't know how that happened.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
qdevices/qnetd-algo-2nodelms.c [new file with mode: 0644]
qdevices/qnetd-algo-2nodelms.h [new file with mode: 0644]
qnetd-algo-2nodelms.c [deleted file]
qnetd-algo-2nodelms.h [deleted file]

diff --git a/qdevices/qnetd-algo-2nodelms.c b/qdevices/qnetd-algo-2nodelms.c
new file mode 100644 (file)
index 0000000..1639267
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2015 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*
+ * This is a simple 'last man standing' algorithm for 2 node clusters
+ *
+ * If the node is the only one left in the cluster that can see the
+ * qdevice server then we return a vote.
+ *
+ * If more than one node can see the qdevice server but the nodes can't
+ * see each other then we return a vote to the lowest nodeID of the two
+ *
+ * If there are more than two nodes, then we don't return a vote.
+ * this is not our job (any other ideas??)
+ */
+
+#include <sys/types.h>
+
+#include <string.h>
+#include <limits.h>
+
+#include "qnetd-algo-2nodelms.h"
+#include "qnetd-log.h"
+#include "qnetd-cluster-list.h"
+
+struct qnetd_algo_2nodelms_info {
+       int num_config_nodes;
+       enum tlv_vote last_result;
+       struct tlv_ring_id ring_id;
+};
+
+
+enum tlv_reply_error_code
+qnetd_algo_2nodelms_client_init(struct qnetd_client *client)
+{
+       struct qnetd_algo_2nodelms_info *info;
+
+       info = malloc(sizeof(struct qnetd_algo_2nodelms_info));
+       if (!info) {
+               return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
+       }
+       client->algorithm_data = info;
+       info->last_result = TLV_VOTE_ASK_LATER;
+       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+}
+
+/*
+ * Called after client sent configuration node list
+ * All client fields are already set. Nodes is actual node list, initial is used
+ * to distinquish between initial node list and changed node list.
+ * msg_seq_num is 32-bit number set by client. If client sent config file version,
+ * config_version_set is set to 1 and config_version contains valid config file version.
+ *
+ * Function has to return result_vote. This can be one of ack/nack, ask_later (client
+ * should ask later for a vote) or wait_for_reply (client should wait for reply).
+ *
+ * Return TLV_REPLY_ERROR_CODE_NO_ERROR on success, different TLV_REPLY_ERROR_CODE_*
+ * on failure (error is send back to client)
+ */
+enum tlv_reply_error_code
+qnetd_algo_2nodelms_config_node_list_received(struct qnetd_client *client,
+    uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
+    const struct node_list *nodes, int initial, enum tlv_vote *result_vote)
+{
+       struct node_list_entry *node_info;
+       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
+       int node_count = 0;
+
+       /* Check this is a 2 node cluster */
+       TAILQ_FOREACH(node_info, nodes, entries) {
+               node_count++;
+       }
+       info->num_config_nodes = node_count;
+       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
+
+       if (node_count != 2) {
+               qnetd_log(LOG_INFO, "algo-2nodelms: cluster %s does not have 2 configured nodes, it has %d", client->cluster_name, node_count);
+
+               *result_vote = TLV_VOTE_NACK;
+               return (TLV_REPLY_ERROR_CODE_UNSUPPORTED_DECISION_ALGORITHM);
+       }
+
+       *result_vote = TLV_VOTE_ASK_LATER;
+       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+}
+
+/*
+ * Called after client sent membership node list.
+ * All client fields are already set. Nodes is actual node list.
+ * msg_seq_num is 32-bit number set by client. If client sent config file version,
+ * config_version_set is set to 1 and config_version contains valid config file version.
+ * ring_id and quorate are copied from client votequorum callback.
+ *
+ * Function has to return result_vote. This can be one of ack/nack, ask_later (client
+ * should ask later for a vote) or wait_for_reply (client should wait for reply).
+ *
+ * Return TLV_REPLY_ERROR_CODE_NO_ERROR on success, different TLV_REPLY_ERROR_CODE_*
+ * on failure (error is send back to client)
+ */
+
+enum tlv_reply_error_code
+qnetd_algo_2nodelms_membership_node_list_received(struct qnetd_client *client,
+    uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
+    const struct tlv_ring_id *ring_id, enum tlv_quorate quorate,
+    const struct node_list *nodes, enum tlv_vote *result_vote)
+{
+       struct node_list_entry *node_info;
+       struct qnetd_client *other_client;
+       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
+       int node_count = 0;
+       int low_node_id = INT_MAX;
+
+       /* Save this now */
+       memcpy(&info->ring_id, ring_id, sizeof(*ring_id));
+
+       /* If both nodes are present, then we're OK. return a vote */
+       TAILQ_FOREACH(node_info, nodes, entries) {
+               if (node_info->node_state == TLV_NODE_STATE_MEMBER) {
+                       node_count++;
+                       if (node_info->node_id < low_node_id) {
+                               low_node_id = node_info->node_id;
+                       }
+               }
+       }
+
+       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s (client %p nodeid %d) membership list has %d member nodes (ring ID %" PRIu64 ")", client->cluster_name, client, client->node_id, node_count, ring_id->seq);
+       if (node_count == 2) {
+               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running normally. Both nodes active", client->cluster_name);
+               *result_vote = info->last_result = TLV_VOTE_ACK;
+               return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+       }
+
+       /* Now look for other clients connected from this cluster that can't see us any more */
+       TAILQ_FOREACH(other_client, &client->cluster->client_list, cluster_entries) {
+               struct qnetd_algo_2nodelms_info *other_info = other_client->algorithm_data;
+
+               if (other_client == client) {
+                       continue; /* We've seen our membership list */
+               }
+               TAILQ_FOREACH(node_info, &other_client->last_membership_node_list, entries) {
+                       if (node_info->node_state == TLV_NODE_STATE_MEMBER) {
+                               node_count++;
+                               qnetd_log(LOG_DEBUG, "algo-2nodelms: seen nodeid %d on client %p (ring ID %" PRIu64 ")", node_info->node_id, other_client, other_info->ring_id.seq);
+                               if (node_info->node_id < low_node_id) {
+                                       low_node_id = node_info->node_id;
+                               }
+                       }
+               }
+       }
+       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s %d nodes running independently", client->cluster_name, node_count);
+
+       /* Only 1 node alive .. allow it to continue */
+       if (node_count == 1) {
+               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on 'last-man'", client->cluster_name);
+               *result_vote = info->last_result = TLV_VOTE_ACK;
+               return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+       }
+
+       /* Both nodes are alive. Only give a vote to the lowest node ID */
+       /* More config options will be made available later ... */
+       if (client->node_id == low_node_id) {
+               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on low-node-id %d", client->cluster_name, low_node_id);
+               *result_vote = info->last_result = TLV_VOTE_ACK;
+       }
+       else {
+               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because lower nodeid %d is active", client->cluster_name, client->node_id, low_node_id);
+               *result_vote = info->last_result = TLV_VOTE_NACK;
+       }
+
+       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+}
+
+/*
+ * Called after client disconnect. Client structure is still existing (and it's part
+ * of a client->cluster), but it is destroyed (and removed from cluster) right after
+ * this callback finishes. Callback is used mainly for destroing client->algorithm_data.
+ */
+void
+qnetd_algo_2nodelms_client_disconnect(struct qnetd_client *client, int server_going_down)
+{
+       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
+           "disconnect", client, client->cluster_name, client->node_id);
+
+       qnetd_log(LOG_INFO, "algo-2nodelms:   server going down %u", server_going_down);
+
+       free(client->algorithm_data);
+}
+
+/*
+ * Called after client sent ask for vote message. This is usually happening after server
+ * replied TLV_VOTE_ASK_LATER.
+ */
+enum tlv_reply_error_code
+qnetd_algo_2nodelms_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num,
+    enum tlv_vote *result_vote)
+{
+       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
+
+       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
+           "asked for a vote", client, client->cluster_name, client->node_id);
+
+       *result_vote =  info->last_result;
+
+       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+}
+
+enum tlv_reply_error_code
+qnetd_algo_2nodelms_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
+{
+
+       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
+           "replied back to vote info message", client, client->cluster_name, client->node_id);
+
+       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
+}
+
+
+static struct qnetd_algorithm qnetd_algo_2nodelms = {
+       .init                          = qnetd_algo_2nodelms_client_init,
+       .config_node_list_received     = qnetd_algo_2nodelms_config_node_list_received,
+       .membership_node_list_received = qnetd_algo_2nodelms_membership_node_list_received,
+       .client_disconnect             = qnetd_algo_2nodelms_client_disconnect,
+       .ask_for_vote_received         = qnetd_algo_2nodelms_ask_for_vote_received,
+       .vote_info_reply_received      = qnetd_algo_2nodelms_vote_info_reply_received,
+};
+
+enum tlv_reply_error_code qnetd_algo_2nodelms_register()
+{
+       return qnetd_algorithm_register(TLV_DECISION_ALGORITHM_TYPE_2NODELMS, &qnetd_algo_2nodelms);
+}
diff --git a/qdevices/qnetd-algo-2nodelms.h b/qdevices/qnetd-algo-2nodelms.h
new file mode 100644 (file)
index 0000000..984e619
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QNETD_ALGO_2NODELMS_H_
+#define _QNETD_ALGO_2NODELMS_H_
+
+#include "qnetd-algorithm.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern enum tlv_reply_error_code       qnetd_algo_2nodelms_client_init(struct qnetd_client *client);
+
+extern enum tlv_reply_error_code       qnetd_algo_2nodelms_config_node_list_received(
+    struct qnetd_client *client, uint32_t msg_seq_num, int config_version_set,
+    uint64_t config_version, const struct node_list *nodes, int initial,
+    enum tlv_vote *result_vote);
+
+extern enum tlv_reply_error_code       qnetd_algo_2nodelms_membership_node_list_received(
+    struct qnetd_client *client, uint32_t msg_seq_num, int config_version_set,
+    uint64_t config_version, const struct tlv_ring_id *ring_id, enum tlv_quorate quorate,
+    const struct node_list *nodes, enum tlv_vote *result_vote);
+
+extern void                            qnetd_algo_2nodelms_client_disconnect(
+    struct qnetd_client *client, int server_going_down);
+
+extern enum tlv_reply_error_code       qnetd_algo_2nodelms_ask_for_vote_received(
+    struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote *result_vote);
+
+extern enum tlv_reply_error_code       qnetd_algo_2nodelms_vote_info_reply_received(
+    struct qnetd_client *client, uint32_t msg_seq_num);
+
+extern enum tlv_reply_error_code qnetd_algo_2nodelms_register(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _QNETD_ALGO_2NODELMS_H_ */
diff --git a/qnetd-algo-2nodelms.c b/qnetd-algo-2nodelms.c
deleted file mode 100644 (file)
index 1639267..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (c) 2015 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Jan Friesse (jfriesse@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the Red Hat, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-/*
- * This is a simple 'last man standing' algorithm for 2 node clusters
- *
- * If the node is the only one left in the cluster that can see the
- * qdevice server then we return a vote.
- *
- * If more than one node can see the qdevice server but the nodes can't
- * see each other then we return a vote to the lowest nodeID of the two
- *
- * If there are more than two nodes, then we don't return a vote.
- * this is not our job (any other ideas??)
- */
-
-#include <sys/types.h>
-
-#include <string.h>
-#include <limits.h>
-
-#include "qnetd-algo-2nodelms.h"
-#include "qnetd-log.h"
-#include "qnetd-cluster-list.h"
-
-struct qnetd_algo_2nodelms_info {
-       int num_config_nodes;
-       enum tlv_vote last_result;
-       struct tlv_ring_id ring_id;
-};
-
-
-enum tlv_reply_error_code
-qnetd_algo_2nodelms_client_init(struct qnetd_client *client)
-{
-       struct qnetd_algo_2nodelms_info *info;
-
-       info = malloc(sizeof(struct qnetd_algo_2nodelms_info));
-       if (!info) {
-               return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
-       }
-       client->algorithm_data = info;
-       info->last_result = TLV_VOTE_ASK_LATER;
-       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-}
-
-/*
- * Called after client sent configuration node list
- * All client fields are already set. Nodes is actual node list, initial is used
- * to distinquish between initial node list and changed node list.
- * msg_seq_num is 32-bit number set by client. If client sent config file version,
- * config_version_set is set to 1 and config_version contains valid config file version.
- *
- * Function has to return result_vote. This can be one of ack/nack, ask_later (client
- * should ask later for a vote) or wait_for_reply (client should wait for reply).
- *
- * Return TLV_REPLY_ERROR_CODE_NO_ERROR on success, different TLV_REPLY_ERROR_CODE_*
- * on failure (error is send back to client)
- */
-enum tlv_reply_error_code
-qnetd_algo_2nodelms_config_node_list_received(struct qnetd_client *client,
-    uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
-    const struct node_list *nodes, int initial, enum tlv_vote *result_vote)
-{
-       struct node_list_entry *node_info;
-       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
-       int node_count = 0;
-
-       /* Check this is a 2 node cluster */
-       TAILQ_FOREACH(node_info, nodes, entries) {
-               node_count++;
-       }
-       info->num_config_nodes = node_count;
-       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
-
-       if (node_count != 2) {
-               qnetd_log(LOG_INFO, "algo-2nodelms: cluster %s does not have 2 configured nodes, it has %d", client->cluster_name, node_count);
-
-               *result_vote = TLV_VOTE_NACK;
-               return (TLV_REPLY_ERROR_CODE_UNSUPPORTED_DECISION_ALGORITHM);
-       }
-
-       *result_vote = TLV_VOTE_ASK_LATER;
-       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-}
-
-/*
- * Called after client sent membership node list.
- * All client fields are already set. Nodes is actual node list.
- * msg_seq_num is 32-bit number set by client. If client sent config file version,
- * config_version_set is set to 1 and config_version contains valid config file version.
- * ring_id and quorate are copied from client votequorum callback.
- *
- * Function has to return result_vote. This can be one of ack/nack, ask_later (client
- * should ask later for a vote) or wait_for_reply (client should wait for reply).
- *
- * Return TLV_REPLY_ERROR_CODE_NO_ERROR on success, different TLV_REPLY_ERROR_CODE_*
- * on failure (error is send back to client)
- */
-
-enum tlv_reply_error_code
-qnetd_algo_2nodelms_membership_node_list_received(struct qnetd_client *client,
-    uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
-    const struct tlv_ring_id *ring_id, enum tlv_quorate quorate,
-    const struct node_list *nodes, enum tlv_vote *result_vote)
-{
-       struct node_list_entry *node_info;
-       struct qnetd_client *other_client;
-       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
-       int node_count = 0;
-       int low_node_id = INT_MAX;
-
-       /* Save this now */
-       memcpy(&info->ring_id, ring_id, sizeof(*ring_id));
-
-       /* If both nodes are present, then we're OK. return a vote */
-       TAILQ_FOREACH(node_info, nodes, entries) {
-               if (node_info->node_state == TLV_NODE_STATE_MEMBER) {
-                       node_count++;
-                       if (node_info->node_id < low_node_id) {
-                               low_node_id = node_info->node_id;
-                       }
-               }
-       }
-
-       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s (client %p nodeid %d) membership list has %d member nodes (ring ID %" PRIu64 ")", client->cluster_name, client, client->node_id, node_count, ring_id->seq);
-       if (node_count == 2) {
-               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running normally. Both nodes active", client->cluster_name);
-               *result_vote = info->last_result = TLV_VOTE_ACK;
-               return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-       }
-
-       /* Now look for other clients connected from this cluster that can't see us any more */
-       TAILQ_FOREACH(other_client, &client->cluster->client_list, cluster_entries) {
-               struct qnetd_algo_2nodelms_info *other_info = other_client->algorithm_data;
-
-               if (other_client == client) {
-                       continue; /* We've seen our membership list */
-               }
-               TAILQ_FOREACH(node_info, &other_client->last_membership_node_list, entries) {
-                       if (node_info->node_state == TLV_NODE_STATE_MEMBER) {
-                               node_count++;
-                               qnetd_log(LOG_DEBUG, "algo-2nodelms: seen nodeid %d on client %p (ring ID %" PRIu64 ")", node_info->node_id, other_client, other_info->ring_id.seq);
-                               if (node_info->node_id < low_node_id) {
-                                       low_node_id = node_info->node_id;
-                               }
-                       }
-               }
-       }
-       qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s %d nodes running independently", client->cluster_name, node_count);
-
-       /* Only 1 node alive .. allow it to continue */
-       if (node_count == 1) {
-               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on 'last-man'", client->cluster_name);
-               *result_vote = info->last_result = TLV_VOTE_ACK;
-               return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-       }
-
-       /* Both nodes are alive. Only give a vote to the lowest node ID */
-       /* More config options will be made available later ... */
-       if (client->node_id == low_node_id) {
-               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on low-node-id %d", client->cluster_name, low_node_id);
-               *result_vote = info->last_result = TLV_VOTE_ACK;
-       }
-       else {
-               qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because lower nodeid %d is active", client->cluster_name, client->node_id, low_node_id);
-               *result_vote = info->last_result = TLV_VOTE_NACK;
-       }
-
-       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-}
-
-/*
- * Called after client disconnect. Client structure is still existing (and it's part
- * of a client->cluster), but it is destroyed (and removed from cluster) right after
- * this callback finishes. Callback is used mainly for destroing client->algorithm_data.
- */
-void
-qnetd_algo_2nodelms_client_disconnect(struct qnetd_client *client, int server_going_down)
-{
-       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
-           "disconnect", client, client->cluster_name, client->node_id);
-
-       qnetd_log(LOG_INFO, "algo-2nodelms:   server going down %u", server_going_down);
-
-       free(client->algorithm_data);
-}
-
-/*
- * Called after client sent ask for vote message. This is usually happening after server
- * replied TLV_VOTE_ASK_LATER.
- */
-enum tlv_reply_error_code
-qnetd_algo_2nodelms_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num,
-    enum tlv_vote *result_vote)
-{
-       struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
-
-       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
-           "asked for a vote", client, client->cluster_name, client->node_id);
-
-       *result_vote =  info->last_result;
-
-       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-}
-
-enum tlv_reply_error_code
-qnetd_algo_2nodelms_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
-{
-
-       qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id %"PRIx32") "
-           "replied back to vote info message", client, client->cluster_name, client->node_id);
-
-       return (TLV_REPLY_ERROR_CODE_NO_ERROR);
-}
-
-
-static struct qnetd_algorithm qnetd_algo_2nodelms = {
-       .init                          = qnetd_algo_2nodelms_client_init,
-       .config_node_list_received     = qnetd_algo_2nodelms_config_node_list_received,
-       .membership_node_list_received = qnetd_algo_2nodelms_membership_node_list_received,
-       .client_disconnect             = qnetd_algo_2nodelms_client_disconnect,
-       .ask_for_vote_received         = qnetd_algo_2nodelms_ask_for_vote_received,
-       .vote_info_reply_received      = qnetd_algo_2nodelms_vote_info_reply_received,
-};
-
-enum tlv_reply_error_code qnetd_algo_2nodelms_register()
-{
-       return qnetd_algorithm_register(TLV_DECISION_ALGORITHM_TYPE_2NODELMS, &qnetd_algo_2nodelms);
-}
diff --git a/qnetd-algo-2nodelms.h b/qnetd-algo-2nodelms.h
deleted file mode 100644 (file)
index 984e619..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2015 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Jan Friesse (jfriesse@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the Red Hat, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _QNETD_ALGO_2NODELMS_H_
-#define _QNETD_ALGO_2NODELMS_H_
-
-#include "qnetd-algorithm.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern enum tlv_reply_error_code       qnetd_algo_2nodelms_client_init(struct qnetd_client *client);
-
-extern enum tlv_reply_error_code       qnetd_algo_2nodelms_config_node_list_received(
-    struct qnetd_client *client, uint32_t msg_seq_num, int config_version_set,
-    uint64_t config_version, const struct node_list *nodes, int initial,
-    enum tlv_vote *result_vote);
-
-extern enum tlv_reply_error_code       qnetd_algo_2nodelms_membership_node_list_received(
-    struct qnetd_client *client, uint32_t msg_seq_num, int config_version_set,
-    uint64_t config_version, const struct tlv_ring_id *ring_id, enum tlv_quorate quorate,
-    const struct node_list *nodes, enum tlv_vote *result_vote);
-
-extern void                            qnetd_algo_2nodelms_client_disconnect(
-    struct qnetd_client *client, int server_going_down);
-
-extern enum tlv_reply_error_code       qnetd_algo_2nodelms_ask_for_vote_received(
-    struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote *result_vote);
-
-extern enum tlv_reply_error_code       qnetd_algo_2nodelms_vote_info_reply_received(
-    struct qnetd_client *client, uint32_t msg_seq_num);
-
-extern enum tlv_reply_error_code qnetd_algo_2nodelms_register(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _QNETD_ALGO_2NODELMS_H_ */