本文整理汇总了Python中system.MogamiLog类的典型用法代码示例。如果您正苦于以下问题:Python MogamiLog类的具体用法?Python MogamiLog怎么用?Python MogamiLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MogamiLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
def open(self, path, flag, mode):
"""open handler.
@param path file path
@param flag flags for open(2)
@param mode open mode (may be empty tuple): actual value is mode[0]
"""
if self.meta_rep.access(path, os.F_OK) == True:
# When the required file exist...
try:
MogamiLog.debug("!!find the file %s w/ %o" % (path, flag))
affinity = self.c_channel.getpeername()
(dest, data_path, fsize) = self.meta_rep.open(
path, flag, mode, affinity)
# create data to send
ans = 0
created = False
except Exception, e:
MogamiLog.debug("!!find the file but error for %s (%s)" %
(path, e))
try:
ans = e.errno
except Exception, e:
ans = errno.ENOENT
dest = None
fd = None
data_path = None
fsize = None
created = False
示例2: utime
def utime(self, path, times):
MogamiLog.debug("path = %s, times = %s" % (path, str(times)))
try:
self.meta_rep.utime(path, times)
ans = 0
except os.error, e:
ans = e.errno
示例3: fgetattr
def fgetattr(self, fd):
try:
st = os.fstat(fd)
senddata = [0, st]
except os.error, e:
MogamiLog.debug("OSError in fgetattr (%s)" % (e))
senddata = [e.errno, 'null']
示例4: send_delete_request
def send_delete_request(self, ip, files):
MogamiLog.debug("file delete request was sent (%s -> %s)" %
(ip, str(files)))
c_channel = channel.MogamiChanneltoData(ip)
ans = c_channel.delfile_req(files)
c_channel.close_req()
c_channel.finalize()
示例5: rename
def rename(self, oldpath, newpath):
MogamiLog.debug(oldpath + ' -> ' + newpath)
try:
self.meta_rep.rename(oldpath, newpath)
ans = 0
except os.error, e:
ans = e.errno
示例6: rmdir
def rmdir(self, path):
MogamiLog.debug("path=%s" % (path))
try:
self.meta_rep.rmdir(path)
ans = 0
except os.error, e:
ans = e.errno
示例7: dataadd
def dataadd(self, rootpath):
ip = self.c_channel.getpeername()
self.sysinfo.add_data_server(ip, rootpath)
MogamiLog.info("delete data server IP: %s" % ip)
MogamiLog.info("Now there are %d data servers." %
len(self.sysinfo.data_list))
示例8: mkdir
def mkdir(self, path, mode):
MogamiLog.debug("path = %s mode = %o" % (path, mode))
try:
self.meta_rep.mkdir(path, mode)
ans = 0
except os.error, e:
ans = e.errno
示例9: __init__
def __init__(self, metaaddr, rootpath):
"""This is the function of MogamiMeta's init.
@param metaaddr ip address or hostname of metadata server
@param rootpath path of directory to store data into
"""
# basic information
self.metaaddr = metaaddr
self.rootpath = os.path.abspath(rootpath)
self.filedict = MogamiLocalFileDict()
# check directory for data files
assert os.access(self.rootpath, os.R_OK and os.W_OK and os.X_OK)
# Initialization of Log.
MogamiLog.init(MogamiLog.TYPE_DATA, conf.data_loglevel)
MogamiLog.info("Start initialization...")
MogamiLog.debug("rootpath = " + self.rootpath)
# At first, connect to metadata server and send request to attend.
self.m_channel = channel.MogamiChanneltoMeta()
self.m_channel.connect(self.metaaddr)
MogamiLog.debug("Success in creating connection to metadata server")
self.m_channel.dataadd_req(self.rootpath)
MogamiLog.info("Init complete!!")
示例10: chmod
def chmod(self, path, mode):
MogamiLog.debug("path = %s w/ mode %s" % (path, oct(mode)))
try:
self.meta_rep.chmod(path, mode)
ans = 0
except os.error, e:
ans = e.errno
示例11: chown
def chown(self, path, uid, gid):
MogamiLog.debug("path=%s uid=%d gid=%d" % (path, uid, gid))
try:
self.meta_rep.chown(path, uid, gid)
ans = 0
except os.error, e:
ans = e.errno
示例12: release
def release(self, flags):
if conf.ap is True:
start_t = time.time()
MogamiLog.debug("** release **")
MogamiLog.critical("** file log ** file:%s\tcmd:%s\tlocal:%s\tread:%s\twrite:%s" % (
self.path, self.cmd, str(self.local), str(self.read_size), str(self.write_size)))
fsize = self.mogami_file.release(flags)
ans = m_channel.release_req(self.path, fsize)
# delete file size cache
if self.path in file_size_dict:
del file_size_dict[self.path]
if conf.ap is True:
# prepare data to tell access pattern
myname = m_channel.getmyname()
(read_data, write_data) = self.access_pattern.mk_form_data()
pid = self.access_pattern.pid
cmd_args = self.access_pattern.cmd_args
path = self.access_pattern.path
# get pids of parents
parents_list = self.access_pattern.parents_list
end_t = time.time()
self.took_time += end_t - start_t
# put file access history to repository
if cmd_args != None:
file_access_rep.put_ap((cmd_args, pid, path, myname,
self.took_time, self.created,
read_data, write_data),
pid, parents_list)
return 0
示例13: read
def read(self, length, offset):
"""read handler.
@param length request size of read
@param offset offset of read request
@return data read from file (may return errno with error)
"""
if conf.ap is True:
start_t = time.time()
MogamiLog.debug("**read offset=%d, length=%d" % (offset, length))
ret_buf = self.mogami_file.read(length, offset)
if conf.ap is True:
end_t = time.time()
self.access_pattern.insert_data(self.access_pattern.read, offset,
len(ret_buf))
self.took_time += end_t - start_t
with self.ap_lock:
self.read_size += len(ret_buf)
return ret_buf
示例14: symlink
def symlink(self, frompath, topath):
MogamiLog.debug("frompath = %s, topath = %s" % (frompath, topath))
try:
self.meta_rep.symlink(frompath, topath)
ans = 0
except os.error, e:
ans = e.errno
示例15: datadel
def datadel(self, ):
ip = self.c_channel.getpeername()
ret = self.sysinfo.remove_data_server(ip)
if ret == True:
MogamiLog.info("delete data server IP: %s" % ip)
MogamiLog.info("Now there are %d data servers." %
len(self.sysinfo.data_list))