def main(): opt = Configuration() opt.backing_store = '/tmp' opt.instance_type = 'master' opt.forcedinitialtype = 'master' opt.backingstorestate = '../tests/mangler.bsc' opt.server_port = 8000 opt.validate() # fake, and never instantiated opt2 = Configuration() opt2.backing_store = '/tmp' opt2.instance_type = 'master' opt2.forcedinitialtype = 'master' opt2.backingstorestate = '../tests/mangler2.bsc' opt2.server_port = 6666 opt2.initial_connect_list = [('blah', 3330)] opt2.validate() import pdb # pdb.set_trace() k = kernel.Kernel(opt) k.fsinit() some_state = State(opt2, ("me2", 6666)) # also never instantiated
def fsinit(self): # print "fsinit %s" % threading.current_thread() # Do some dirty hacking to get things running self.kernel = kernel.Kernel(self.options) # start threads in here self.kernel.fsinit() self.logger = self.kernel.logger
def main(): raise Exception("DEPRECATED") opt = Configuration() opt.backingstore = '/tmp/server' opt.instance_type = 'master' opt.forcedinitialtype = 'master' opt.backingstorestate = '../tests/fusebypass.bsc' opt.serverport = 8000 opt.validate() import pdb # pdb.set_trace() k = kernel.Kernel(opt) k.fsinit() print "!! Getattr on '/': %s" % k.getattr(None, "/") # d = GRSDirectory('/') print "!! Readdir on '/': %s" % k.readdir(None, "/", 0) f = GRSFile('/hello', os.O_RDONLY) assert f.file is not None and f.file >= 1 print "!! Read: ", f.read(-1, 0) print "!! Success on last test" import random print "!! Testing that we detect too few peers correctly" filename = '/file%d' % random.randint(1000, 9999) w_f = GRSFile(filename, os.O_CREAT | os.O_WRONLY) # print "Errno EROFS %d" % errno.EROFS assert w_f.file is not None and w_f.file == -30 print "!! Success on last test" print "!! Writing to %s" % filename opt.maxcopies = 0 opt.mincopies = 0 w_f = GRSFile(filename, os.O_CREAT | os.O_WRONLY) # print "Errno EROFS %d" % errno.EROFS assert w_f.file is not None and w_f.file >= 1 w_f.write("Some string goes here %s\n" % random.randint(0, 10000000), 0) w_f.flush() w_f.release(w_f.flags) r_f = GRSFile(filename, os.O_RDONLY) assert r_f.file is not None and r_f.file >= 1 print "!! Read: ", r_f.read(-1, 0) r_f.release(r_f.flags)
def main(): opt = Configuration() node_id = 8000 opt.backingstore = '/tmp/node%s' % node_id opt.backingstorestate = '../tests/nettest_node%s.bsc' % node_id opt.serverport = node_id opt.maxcopies = 0 opt.mincopies = 0 opt.logquiet = False opt.logverbose = True opt.logverbosity = 3 opt.validate() k = kernel.Kernel(opt) k.fsinit() test_filename = 'hello' test_path = os.path.join(os.sep, test_filename) print "Instance started" try: print "!! Getattr on '/': %s" % k.getattr("/", None) print "!! Readdir on '/': %s" % k.readdir("/", 0, None) # Root dir may be empty if test_filename in k.readdir("/", 0, None): f = GRSFile(test_path, os.O_RDONLY) assert f.file is not None and f.file >= 1 print "!! Read %s:\n%s" % (test_path, f.read(-1, 0)) print "!! Success on last test" attrs = f.fgetattr() print "!! Fgetattrs %s" % attrs import random filename = '/file%d' % random.randint(1000, 9999) print "!! Writing to %s" % filename w_f = GRSFile(filename, os.O_CREAT | os.O_WRONLY) # print "Errno EROFS %d" % errno.EROFS assert w_f.file is not None and w_f.file >= 1 w_f.write("Some string goes here %s\n" % random.randint(0, 10000000), 0) w_f.flush() w_f.release(w_f.open_args[1]) r_f = GRSFile(filename, os.O_RDONLY) assert r_f.file is not None and r_f.file >= 1 print "!! Read: ", r_f.read(-1, 0) r_f.release(r_f.open_args[1]) # append mode filename = "/file_a" print "!! appending to %s" % filename w_f = GRSFile(filename, os.O_CREAT | os.O_WRONLY | os.O_APPEND) assert w_f.file is not None and w_f.file >= 1 w_f.write("mary", 0) w_f.flush() w_f.release(w_f.open_args[1]) print "!! -- first part written" w_f = GRSFile(filename, os.O_WRONLY | os.O_APPEND) assert w_f.file is not None and w_f.file >= 1 w_f.write("mary", 5) w_f.flush() w_f.release(w_f.open_args[1]) r_f = GRSFile(filename, os.O_RDONLY) assert r_f.file is not None and r_f.file >= 1 print "!! Read: ", r_f.read(-1, 0) r_f.release(r_f.open_args[1]) # Root dir may be empty if test_filename in k.readdir("/", 0, None): k.utime(test_path, (time.time(), time.time()), None) else: print "!! Creating test file %s for future runs" % test_path w_f = GRSFile(test_path, os.O_CREAT | os.O_WRONLY) assert w_f.file is not None and w_f.file >= 1 w_f.write("Hello grid file system!\n", 0) w_f.flush() w_f.release(w_f.open_args[1]) finally: k.fshalt()
def main(): # yappi.start() if len(sys.argv) < 2: print "Must supply node id [0,1,2] as argument" sys.exit(1) no = sys.argv[1] do_write = len(sys.argv) >= 3 opt = Configuration() node_id = 8000 + int(no) opt.backingstore = '/tmp/node%s' % node_id if node_id > 8000: # anti-idiot opt.initial_connect_list = [('ubuntu1', 8000)] opt.backingstorestate = '../tests/nettest_node%s.bsc' % no opt.serverport = node_id opt.logverbosity = 3 # opt.maxcopies = 0 # opt.mincopies = 0 opt.validate() k = kernel.Kernel(opt) k.fsinit() print "Instance started" # instance started, now start other instances and see what happens wait_time = (2 if opt.mincopies == 0 else 15) print "Sleeping %d seconds to allow others to get off the ground" % wait_time time.sleep(wait_time / 2) print "Attempting actions" try: print "!! Getattr on '/': %s" % k.getattr("/", None) print "!! Readdir on '/': %s" % k.readdir("/", 0, None) f = GRSFile('/hello', os.O_RDONLY) assert f.file is not None and f.file >= 1 print "!! Read: ", f.read(-1, 0) print "!! Success on last test" attrs = f.fgetattr() print "!! Fgetattrs %s" % attrs if not do_write or k.state.get_instancetype() > 1: print "!!!! No writes requested or not master" time.sleep(90) return opt.maxcopies = 1 opt.mincopies = 1 import random filename = '/file%d' % random.randint(1000, 9999) print "!! Writing to %s" % filename w_f = GRSFile(filename, os.O_CREAT|os.O_WRONLY) # print "Errno EROFS %d" % errno.EROFS assert w_f.file is not None and w_f.file >= 1 w_f.write("Some string goes here %s\n" % random.randint(0, 10000000), 0) w_f.flush() w_f.release(w_f.open_args[1]) r_f = GRSFile(filename, os.O_RDONLY) assert r_f.file is not None and r_f.file >= 1 print "!! Read: ", r_f.read(-1, 0) r_f.release(r_f.open_args[1]) k.utime("/hello", (time.time(), time.time()), None) finally: k.fshalt()