Permalink
Browse files

Cleaning INFOCOM tests

  • Loading branch information...
1 parent 3aaf25b commit 76e04490cecc1389c7924c80c61ddb027ec4424c @llpamies committed Jul 9, 2012
View
@@ -1 +1 @@
-a;skugal;jkdfgafdg
+(C) Lluis Pamies-Juarez
View
@@ -1,18 +1,29 @@
#!/usr/bin/env python
+from __future__ import division
import os
import sys
+import platform
sys.path.append(os.getcwd())
-sys.path.append(os.getcwd()+'/lib/')
+if platform.architecture()==('32bit', 'ELF'):
+ sys.path.append(os.getcwd()+'/lib/')
+elif platform.architecture()==('64bit', 'ELF'):
+ sys.path.append(os.getcwd()+'/lib64/')
+else:
+ raise OSError('Platform is not supported.')
import logging
-import logging.config
import argparse
from clusterdfs.processname import setprocname
from clusterdfs.datanode import DataNodeConfig, DataNode
if __name__ == '__main__':
- logging.config.fileConfig("./bin/datanode_logger.conf")
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ h = logging.StreamHandler()
+ h.setFormatter(logging.Formatter("%(levelname)s: %(name)s - %(message)s"))
+ logger.addHandler(h)
+
if '--optimize' in sys.argv:
logging.info('Running optimized version!')
sys.argv.remove('--optimize')
@@ -28,6 +39,7 @@ if __name__ == '__main__':
parser.add_argument('-na', action="store", default='localhost', dest="namenode_addr", type=str, help="Address of the NameNode.")
parser.add_argument('-np', action="store", default=7770, dest="namenode_port", type=int, help="Port of the NameNode.")
parser.add_argument('-i', action="store", default=False, dest="isolated", type=bool, help="Should the data node work without namenode.")
+ parser.add_argument('-f', action="store", default=False, dest="fakeout", type=bool, help="When set all new blocks are stored to /dev/null.")
config = DataNodeConfig.from_args(parser.parse_args())
try:
@@ -13,7 +13,7 @@ level = DEBUG
qualname = root
[handler_console]
-class = StreamHandler
+class = logging.StreamHandler
level = DEBUG
formatter = generic
args = (sys.stdout,)
View
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-import os
-import sys
-sys.path.append(os.getcwd())
-
-import sys
-import os.path
-from datanode import DataNodeHeader
-from bufferedio import FileBufferedIO
-from networking import *
-
-class DFS(Client):
- def store(self, path):
- length = os.path.getsize(path)
- header = {'op':DataNodeHeader.OP_STORE, 'length':length, 'id':path.split('/')[-1]}
- header['fwdlist'] = [('172.21.48.151',7777)]
- print header
- self.send(header)
- FileBufferedIO(path, lambda d: self.socket.sendall(d)).run()
- result = self.recv()
- print result
-
- def retrieve(self, name, path):
- header = {'op':DataNodeHeader.OP_RETRIEVE, 'id':name}
- print header
- self.send(header)
- size = self.recv()
- f = open(path, 'wb')
- for data in SocketIterable(self.socket, size):
- f.write(data)
- f.close()
- result = self.recv()
- print result
-
-if __name__=='__main__':
- server = sys.argv[1]
- port = int(sys.argv[2])
- dfs = DFS(server, port)
-
- operation = sys.argv[3]
- if operation=='STORE':
- path = sys.argv[4]
- dfs.store(path)
- elif operation=='RETRIEVE':
- name = sys.argv[4]
- path = sys.argv[5]
- dfs.retrieve(name, path)
- else:
- assert False
View
@@ -1,9 +1,18 @@
#!/usr/bin/env python
+'''
+WARNING: The namenode is not fully implemented yet...
+'''
+from __future__ import division
import os
import sys
-
-sys.path.append(os.getcwd()+'/lib')
+import platform
sys.path.append(os.getcwd())
+if platform.architecture()==('32bit', 'ELF'):
+ sys.path.append(os.getcwd()+'/lib/')
+elif platform.architecture()==('64bit', 'ELF'):
+ sys.path.append(os.getcwd()+'/lib64/')
+else:
+ raise OSError('Platform is not supported.')
import time
import logging
Oops, something went wrong. Retry.

0 comments on commit 76e0449

Please sign in to comment.