public synchronized int ensureUser(String externalUserId) {
int id = getId(externalUserId);
if (id != USER_NOT_FOUND) {
return id;
}
User user = new User.Builder(externalUserId, Maps.<String, String>newHashMap()).build();
try {
id = idMap.incrementNextAvailableId();
byte[] location = JournalUtil.locationToBytes(userJournal.write(user.toByteBuffer(), true));
MetaData metaData = new MetaData(location);
metaDataList.add(metaData);
idMap.put(externalUserId, id);
return id;
} catch (IOException e) {