public DbManager(String accessKeyId, String secretAccessKey, int numMap, int numReduce) {
    	List<String> domainNames = null; // to store domain names --d3
    	Boolean retry = false; // to retry if anything do not follow up --d3
    	
    	// Initialize simpleDB service
        service = new AmazonSimpleDBClient(accessKeyId, secretAccessKey);
        
        // create the threads to download list from SimpleDB
        workers = new WorkerThreadQueue(Global.numSDBDomain, "DbManager"); //number of threads and names --d3
        
        if ( Global.clientID == 0 )  { // only node 0 creates the domain
        	do {
				try {
					retry = false;
					domainNames = service.listDomains(new ListDomainsRequest()).getListDomainsResult().getDomainName();
				} catch (AmazonSimpleDBException ex) {
					retry = true;
					logger.error("Fail to list domain, will retry: " + ex.getMessage());
					try {Thread.sleep(1000 + (new Random()).nextInt(2000));} catch (Exception ex2) {}
				}
        	} while (retry);
        	if ( !domainNames.contains(dbManagerDomain) ) // the domain cloudmapreduce is in list or not --d3
        		workers.push(new CreateDomainRunnable(dbManagerDomain));
	        for ( int i=0 ; i<Global.numSDBDomain ; i++ ) {   // more domains to achieve high throughput
	        	if ( !domainNames.contains(dbManagerDomain+i) )
	        		workers.push(new CreateDomainRunnable(dbManagerDomain+i));
	        }
	        workers.waitForFinish();
        }
        numSplits = numMap; // splits equal to number of mappers!--d3
        numReduceQ = numReduce;
	}