summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils/syncdaemon/syncdutils.py
diff options
context:
space:
mode:
authorVenky Shankar <venky@gluster.com>2011-10-24 15:29:00 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-04 02:06:44 -0700
commit8e171a03d81452a2998b01997da7647c0b3bf52b (patch)
tree54117831ec7c55fe0b1bb67f9ec227c5fe2059c6 /xlators/features/marker/utils/syncdaemon/syncdutils.py
parentcc0a908bc5d5046bcb2909fc98765038f15e918d (diff)
cli: add geo-replication log-rotate command
Rotating geo-replication master/monitor log files from cli. On invocation, the log file for a given master-slave session is backed up with the current timestamp suffixed to the file name and signal is sent to gsyncd to start logging to a new log file. Sample commands: * Rotate log file for this <master>:<slave> session: gluster volume geo-replication <master> <slave> log-rotate * Rotate log files for all session for master volume <master> gluster volume geo-replication <master> log-rotate * Rotate log files for all sessions: gluster volume geo-replication log-rotate Change-Id: If801743e9f37bd282e68d262203141626ce77e55 BUG: 3519 Reviewed-on: http://review.gluster.com/653 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Csaba Henk <csaba@gluster.com>
Diffstat (limited to 'xlators/features/marker/utils/syncdaemon/syncdutils.py')
-rw-r--r--xlators/features/marker/utils/syncdaemon/syncdutils.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/syncdutils.py b/xlators/features/marker/utils/syncdaemon/syncdutils.py
index 4bf51da74..81c4e2e4b 100644
--- a/xlators/features/marker/utils/syncdaemon/syncdutils.py
+++ b/xlators/features/marker/utils/syncdaemon/syncdutils.py
@@ -5,9 +5,11 @@ import fcntl
import shutil
import logging
from threading import Lock, Thread as baseThread
-from errno import EACCES, EAGAIN
+from errno import EACCES, EAGAIN, EINTR
from signal import SIGTERM, SIGKILL
from time import sleep
+import select as oselect
+from os import waitpid as owaitpid
from gconf import gconf
@@ -158,3 +160,24 @@ class Thread(baseThread):
kw['target'] = twrap
baseThread.__init__(self, *a, **kw)
self.setDaemon(True)
+
+class GsyncdError(Exception):
+ pass
+
+def eintr_wrap(func, exc, *a):
+ """
+ wrapper around syscalls resilient to interrupt caused
+ by signals
+ """
+ while True:
+ try:
+ return func(*a)
+ except exc, ex:
+ if not ex[0] == EINTR:
+ raise GsyncdError(ex[1])
+
+def select(*a):
+ return eintr_wrap(oselect.select, oselect.error, *a)
+
+def waitpid(*a):
+ return eintr_wrap(owaitpid, OSError, *a)