本文整理汇总了Python中libs.System.MogamiLog类的典型用法代码示例。如果您正苦于以下问题:Python MogamiLog类的具体用法?Python MogamiLog怎么用?Python MogamiLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MogamiLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: utime
def utime(self, path, times):
MogamiLog.debug("path = %s, times = %s" % (path, str(times)))
try:
os.utime(path, times)
ans = 0
except os.error, e:
ans = e.errno
示例2: mkdir
def mkdir(self, path, mode):
MogamiLog.debug("path = %s mode = %o" % (path, mode))
try:
os.mkdir(path, mode)
ans = 0
except os.error, e:
ans = e.errno
示例3: rmdir
def rmdir(self, path):
MogamiLog.debug("path=%s" % (path))
try:
os.rmdir(path)
ans = 0
except os.error, e:
ans = e.errno
示例4: __init__
def __init__(self, fsize, dest, data_path, flag, *mode):
MogamiFile.__init__(self, fsize)
self.remote = True
self.dest = dest
self.data_path = data_path
self.flag = flag
self.mode = mode
self.prenum = 1
# calculation of the number of blocks
self.blnum = self.fsize / conf.blsize
if self.fsize % conf.blsize != 0:
self.blnum += 1
# initialization of read buffer
self.r_data = tuple([MogamiBlock() for i in range(self.blnum + 1)])
self.r_buflock = threading.Lock()
MogamiLog.debug("create r_data 0-%d block" % (len(self.r_data)-1))
# initialization of write buffer
self.w_list = []
self.w_data = cStringIO.StringIO()
self.w_buflock = threading.Lock()
self.w_len = 0
# for buffer of dirty data
self.dirty_dict = {}
示例5: chown
def chown(self, path, uid, gid):
MogamiLog.debug("path=%s uid=%d gid=%d" % (path, uid, gid))
try:
os.chown(path, uid, gid)
ans = 0
except os.error, e:
ans = e.errno
示例6: read
def read(self, length, offset):
"""read handler.
return strings read from file
@param length request size of read
@param offset offset of read request
"""
MogamiLog.debug("**read offset=%d, length=%d" % (offset, length))
# check access pattern
#self.access_pattern.check_mode(offset, length)
#self.access_pattern.change_info(offset, ret_str.tell(),
# last_readbl)
"""
if conf.prefetch == True:
if last_readbl != self.access_pattern.last_bl:
#MogamiLog.debug("read: prenum %d \n" % (self.prenum))
if conf.force_prenum == True:
self.prenum = conf.prenum
blnum_list = []
prereq_list = self.access_pattern.return_need_block(
(last_readbl + 1) * 1024 * 1024, self.prenum,
self.blnum)
for prereq in prereq_list:
if prereq > self.blnum:
break
if self.bldata[prereq].state == 0:
blnum_list.append(prereq)
if len(blnum_list) != 0:
self.request_prefetch(blnum_list)
self.calc_time += end_t - start_t"""
return self.mogami_file.read(length, offset)
示例7: rename
def rename(self, oldpath, newpath):
MogamiLog.debug(oldpath + ' -> ' + newpath)
try:
os.rename(oldpath, newpath)
ans = 0
except os.error, e:
ans = e.errno
示例8: chmod
def chmod(self, path, mode):
MogamiLog.debug("path = %s w/ mode %s" % (path, oct(mode)))
try:
os.chmod(path, mode)
ans = 0
except os.error, e:
ans = e.errno
示例9: symlink
def symlink(self, frompath, topath):
MogamiLog.debug("frompath = %s, topath = %s" % (frompath, topath))
try:
os.symlink(frompath, topath)
ans = 0
except os.error, e:
ans = e.errno
示例10: release
def release(self, flags):
if conf.ap == True:
start_t = time.time()
MogamiLog.debug("** release **")
fsize = self.mogami_file.release(flags)
ans = m_channel.release_req(self.metafd, fsize)
# delete file size cache
if self.path in file_size_dict:
del file_size_dict[self.path]
if conf.ap == 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
end_t = time.time()
self.took_time += end_t - start_t
if cmd_args != None:
# process access pattern history (may be inserted to queue)
file_access_queue.put((cmd_args, pid, path, myname,
self.took_time, self.created,
read_data, write_data))
return 0
示例11: __init__
def __init__(self, metaaddr, rootpath, mogami_dir):
"""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
@param mogami_dir path of mogami's root directory
"""
# basic information of metadata server
self.metaaddr = metaaddr
self.rootpath = os.path.abspath(rootpath)
self.mogami_dir = mogami_dir
# 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("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.debug("Init complete!!")
示例12: __init__
def __init__(self, path, flag, *mode):
"""Initializer called when opened.
@param path file path
@param flag flags with open(2)
@param *mode file open mode (may not be specified)
"""
MogamiLog.debug("** open ** path = %s, flag = %s, mode = %s" %
(path, str(flag), str(mode)))
if conf.ap == True:
start_t = time.time()
# parse argurments
self.path = path
self.flag = flag
self.mode = mode
(ans, dest, self.metafd, data_path, self.fsize,
self.created) = m_channel.open_req(path, flag, *mode)
if ans != 0: # error on metadata server
e = IOError()
e.errno = ans
raise e
if dest == 'self':
self.mogami_file = FileManager.MogamiLocalFile(
self.fsize, data_path, flag, *mode)
else:
self.mogami_file = FileManager.MogamiRemoteFile(
self.fsize, dest, data_path, flag, *mode)
ans = self.mogami_file.create_connections(channels)
if ans != 0:
MogamiLog.error("open error !!")
e = IOError()
e.errno = ans
raise e
# register file size to file size dictionary
file_size_dict[path] = self.fsize
if conf.ap == True:
"""Get Id list to know pid.
list = {gid: pid: uid}
And then get the command from pid.
"""
try:
id_list = self.GetContext()
pid = id_list['pid']
f = open(os.path.join("/proc", str(pid), "cmdline"), 'r')
cmd_args = f.read().rsplit('\x00')[:-1]
except Exception, e:
# with any error, pass this part of process
cmd_args = None
pid = -1
self.access_pattern = FileManager.MogamiAccessPattern(
path, cmd_args, pid)
end_t = time.time()
self.took_time = end_t - start_t
示例13: unlink
def unlink(self, path):
MogamiLog.debug("path = %s" % path)
if os.path.isfile(path):
try:
(dest, data_path, fsize) = meta_file_info(path)
self.sysinfo.add_delfile(dest, data_path)
except Exception, e:
MogamiLog.error("cannot remove file contents of %s", path)
示例14: unlink
def unlink(self, path):
"""unlink handler.
@param path path name to unlink
"""
MogamiLog.debug("** unlink ** path = %s" % (path, ))
ans = m_channel.unlink_req(path)
return -ans
示例15: data_add
def data_add(self, ip, rootpath):
self.sysinfo.add_data_server(ip, rootpath)
print "add data server IP:", ip
print "Now %d data servers are." % len(self.sysinfo.data_list)
MogamiLog.info("delete data server IP: %s" % ip)
MogamiLog.info("Now there are %d data servers." %
len(self.sysinfo.data_list))