def newStore(request,store_name): if ContentStore.objects.filter(name=store_name).exists(): resp = { 'ok' : False, 'error' : 'store: %s already exists, please choose another name.' % store_name } return HttpResponse(json.dumps(resp)) replica = int(request.POST.get('replica','2')) partitions = int(request.POST.get('partitions','2')) desc = request.POST.get('desc',"") num_nodes = Node.objects.count() # Check for nodes: if num_nodes == 0: n = Node.objects.create(host=get_local_pub_ip(), online=True, group=Group(pk=1)) num_nodes = 1 if replica > num_nodes: resp = {'ok': False, 'error':'Num of replicas is too big'} return HttpResponse(json.dumps(resp)) store = ContentStore( name=store_name, api_key=generate_api_key(), replica=replica, partitions=partitions, description=desc ) store.save() store.collaborators.add(request.user) store.save() setupCluster(store) resp = store.to_map(True) resp.update({ 'ok' : True, 'kafkaHost' : kafkaHost, 'kafkaPort' : kafkaPort, }) return HttpResponse(json.dumps(resp, ensure_ascii=False, cls=DateTimeAwareJSONEncoder))
def newStore(request,store_name): if ContentStore.objects.filter(name=store_name).exists(): resp = { 'ok' : False, 'error' : 'store: %s already exists, please choose another name.' % store_name } return HttpResponse(json.dumps(resp)) replica = int(request.POST.get('replica','2')) partitions = int(request.POST.get('partitions','2')) desc = request.POST.get('desc',"") num_nodes = Node.objects.count() # Check for nodes: if num_nodes == 0: n = Node.objects.create(host=get_local_pub_ip(), online=True, group=Group(pk=1)) num_nodes = 1 if replica > num_nodes: resp = {'ok': False, 'error':'Num of replicas is too big'} return HttpResponse(json.dumps(resp)) store = ContentStore( name=store_name, api_key=generate_api_key(), replica=replica, partitions=partitions, description=desc ) store.save() store.collaborators.add(request.user) store.save() setupCluster(store) resp = store.to_map(True) resp.update({ 'ok' : True, }) return HttpResponse(json.dumps(resp, ensure_ascii=False, cls=DateTimeAwareJSONEncoder))
# Django settings for sinApp project. import os from utils import get_local_pub_ip LOCAL_PUB_IP = get_local_pub_ip() SIN_HOME = os.path.normpath(os.path.join(os.path.normpath(__file__), '../..')) DEBUG = True TEMPLATE_DEBUG = DEBUG VERSION = 0.1 STORE_HOME = '/tmp/store/' SIN_LISTEN = 8666 SIN_MIN_THREAD = 16 SIN_MAX_THREAD = 512 DISABLE_HOST_CHECK = True ADMINS = ( # ('Your Name', '*****@*****.**'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '/tmp/sin', # Or path to database file if using sqlite3.
# Django settings for sinApp project. import os from utils import get_local_pub_ip LOCAL_PUB_IP = get_local_pub_ip() SIN_HOME = os.path.normpath(os.path.join(os.path.normpath(__file__), '../..')) DEBUG = True TEMPLATE_DEBUG = DEBUG VERSION = 0.1 STORE_HOME = '/tmp/store/' SIN_LISTEN = 8666 SIN_MIN_THREAD = 16 SIN_MAX_THREAD = 512 DISABLE_HOST_CHECK = True ADMINS = ( # ('Your Name', '*****@*****.**'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '/tmp/sin', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3.