| 1899 | } |
| 1900 | |
| 1901 | const char *sentinelHandleConfiguration(char **argv, int argc) { |
| 1902 | |
| 1903 | sentinelRedisInstance *ri; |
| 1904 | |
| 1905 | if (!strcasecmp(argv[0],"monitor") && argc == 5) { |
| 1906 | /* monitor <name> <host> <port> <quorum> */ |
| 1907 | int quorum = atoi(argv[4]); |
| 1908 | |
| 1909 | if (quorum <= 0) return "Quorum must be 1 or greater."; |
| 1910 | if (createSentinelRedisInstance(argv[1],SRI_MASTER,argv[2], |
| 1911 | atoi(argv[3]),quorum,NULL) == NULL) |
| 1912 | { |
| 1913 | return sentinelCheckCreateInstanceErrors(SRI_MASTER); |
| 1914 | } |
| 1915 | } else if (!strcasecmp(argv[0],"down-after-milliseconds") && argc == 3) { |
| 1916 | /* down-after-milliseconds <name> <milliseconds> */ |
| 1917 | ri = sentinelGetMasterByName(argv[1]); |
| 1918 | if (!ri) return "No such master with specified name."; |
| 1919 | ri->down_after_period = atoi(argv[2]); |
| 1920 | if (ri->down_after_period <= 0) |
| 1921 | return "negative or zero time parameter."; |
| 1922 | sentinelPropagateDownAfterPeriod(ri); |
| 1923 | } else if (!strcasecmp(argv[0],"failover-timeout") && argc == 3) { |
| 1924 | /* failover-timeout <name> <milliseconds> */ |
| 1925 | ri = sentinelGetMasterByName(argv[1]); |
| 1926 | if (!ri) return "No such master with specified name."; |
| 1927 | ri->failover_timeout = atoi(argv[2]); |
| 1928 | if (ri->failover_timeout <= 0) |
| 1929 | return "negative or zero time parameter."; |
| 1930 | } else if (!strcasecmp(argv[0],"parallel-syncs") && argc == 3) { |
| 1931 | /* parallel-syncs <name> <milliseconds> */ |
| 1932 | ri = sentinelGetMasterByName(argv[1]); |
| 1933 | if (!ri) return "No such master with specified name."; |
| 1934 | ri->parallel_syncs = atoi(argv[2]); |
| 1935 | } else if (!strcasecmp(argv[0],"notification-script") && argc == 3) { |
| 1936 | /* notification-script <name> <path> */ |
| 1937 | ri = sentinelGetMasterByName(argv[1]); |
| 1938 | if (!ri) return "No such master with specified name."; |
| 1939 | if (access(argv[2],X_OK) == -1) |
| 1940 | return "Notification script seems non existing or non executable."; |
| 1941 | ri->notification_script = sdsnew(argv[2]); |
| 1942 | } else if (!strcasecmp(argv[0],"client-reconfig-script") && argc == 3) { |
| 1943 | /* client-reconfig-script <name> <path> */ |
| 1944 | ri = sentinelGetMasterByName(argv[1]); |
| 1945 | if (!ri) return "No such master with specified name."; |
| 1946 | if (access(argv[2],X_OK) == -1) |
| 1947 | return "Client reconfiguration script seems non existing or " |
| 1948 | "non executable."; |
| 1949 | ri->client_reconfig_script = sdsnew(argv[2]); |
| 1950 | } else if (!strcasecmp(argv[0],"auth-pass") && argc == 3) { |
| 1951 | /* auth-pass <name> <password> */ |
| 1952 | ri = sentinelGetMasterByName(argv[1]); |
| 1953 | if (!ri) return "No such master with specified name."; |
| 1954 | ri->auth_pass = sdsnew(argv[2]); |
| 1955 | } else if (!strcasecmp(argv[0],"auth-user") && argc == 3) { |
| 1956 | /* auth-user <name> <username> */ |
| 1957 | ri = sentinelGetMasterByName(argv[1]); |
| 1958 | if (!ri) return "No such master with specified name."; |
no test coverage detected