Skip to content

Dev - #8

Open
kitallis wants to merge 35 commits into
masterfrom
dev
Open

Dev#8
kitallis wants to merge 35 commits into
masterfrom
dev

Conversation

@kitallis

@kitallis kitallis commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

Work in progress.

kitallis and others added 30 commits January 9, 2017 17:47

@kitallis kitallis left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly some code and convention changes.


(defn init! []
(when (config/lookup :integrate-with-wonko?)
(wonko/init! "agrajag"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this to configuration.

Comment thread src/repmgr_to_zk/monitoring.clj Outdated
(try
(heartbeat)
(standby-cluster)
(failed-cluster)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(standby-cluster) and (failed-cluster) both call (repmgr/nodes-in-cluster): which is not memoized in between. We should call it only once during the duration of this.

Comment thread src/repmgr_to_zk/monitoring.clj Outdated
(heartbeat)
(standby-cluster)
(failed-cluster)
(master-db)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for this (master-db) call. This function internally calls (cluster-status), in which case if you add up the two calls before this, we end up calling (cluster-status) (a shell out) 3 times to post metrics. We only need to do this once.

Comment thread src/repmgr_to_zk/publish.clj Outdated
:name latest-master
:cluster latest-cluster))))

(defn- check-if-new [master-data zk-data]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better name for this function. Maybe (new-master?)

Comment thread src/repmgr_to_zk/publish.clj Outdated
;; (1. publish)
;; (2. exit)

(defn- check-if-accurate []

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better name for this function. Since this is not a boolean check anymore and returns the coalesced version from 2 sources of truth. We can call it coalesced-cluster.

Comment thread src/repmgr_to_zk/publish.clj Outdated
(:event-timestamp zk-data))
0))

(defn check-and-update-status []

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be (update-status) or simply (update).

Comment thread src/repmgr_to_zk/repmgr.clj Outdated

(defn nodes-in-cluster []
(let [cluster (cluster-status)
cluster-map-list (for [role ["master" "FAILED" "standby"]

@kitallis kitallis Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put them in a var. Convert into a single-cased version – preferably, lowercase – in the input before checking.

Comment thread src/repmgr_to_zk/zk.clj
(deserializer bytes))
version (-> zk-data :stat :version)]
(if (predicate? deserialized)
(zk/set-data client path (serializer new-data) version)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the internal (set-data) which has the retry mechanism.

Comment thread src/repmgr_to_zk/zk.clj
(catch KeeperException$SessionExpiredException see ::reinit)
(catch KeeperException$ConnectionLossException cle ::reinit))]
(condp = result
::reinit (do (init!)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to log the exception. This is written in a way where we only return ::reinit from the catch block and we don't have access to see or cle. We can either rewrite it to do the work right in the catch block or return a map of the result and then log the exception from it in the condp block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants