@Override
  public DataStore initializeDataStore(Map<String, String> credentials, boolean force)
      throws InitializationException {

    String userName = credentials.get(PersistencyConstants.USER_NAME);
    if (userName == null) {
      return null;
    }

    DataStore store = new NoSQLDataStore();
    store.initializeStore(credentials, force);

    String domain = MultitenantUtils.getTenantDomain(userName);

    int tenantId;
    try {
      tenantId = UtilsServiceComponent.getRealmService().getTenantManager().getTenantId(domain);
    } catch (UserStoreException e) {
      throw new InitializationException("Unable to get tenant information..", e);
    }

    // int tenantId = CarbonContext.getCurrentContext().getTenantId();
    dataStorePool.put(tenantId, store);

    return store;
  }
  @Override
  public DataStore getDataStore(String userName) throws DataStoreException {

    if (userName == null) {
      return null;
    }

    String domain = MultitenantUtils.getTenantDomain(userName);

    int tenantId;
    try {
      tenantId = UtilsServiceComponent.getRealmService().getTenantManager().getTenantId(domain);
    } catch (UserStoreException e) {
      throw new DataStoreException("Unable to get tenant information..", e);
    }

    // int tenantId = CarbonContext.getCurrentContext().getTenantId();
    return dataStorePool.get(tenantId);
  }