Hi all, I hope you are all doing well...
According to the documentation
<https://docs.mongodb.com/v3.6/reference/limits/>, in MongoDB I can create
a database whose name is up to 64 characters. When I try to connect to a
repository (Oak 1.12.0) that does not exist and use a db name with 64
characters I am getting:
Exception in thread "main" com.mongodb.MongoCommandException: Command
failed with error 73 (InvalidNamespace): 'Invalid database name:
'repository123456789012345678901234567890123456789012345678901234'' on
server 192.168.200.1:37017. The full response is { "ok" : 0.0, "errmsg" :
"Invalid database name:
'repository123456789012345678901234567890123456789012345678901234'", "code"
: 73, "codeName" : "InvalidNamespace" }
After some debugging, I found out that the driver appends .$cmd to the
database name, and with that, exceeds the 64 limit. If I use a db name with
63 it appears to work.
My test class has the following :
public static void main(String[] args) throws RepositoryException {
String repositoryName =
"repository123456789012345678901234567890123456789012345678901234";
OakFileDataStore fileDataStore = new OakFileDataStore();
fileDataStore.setMinRecordLength(0);
File repositoryFolder = new File("E:\\repos", repositoryName);
fileDataStore.init(repositoryFolder.getAbsolutePath());
DataStoreBlobStore dsbs = new DataStoreBlobStore(fileDataStore);
MongoDocumentNodeStoreBuilder builder = new
MongoDocumentNodeStoreBuilder().
setMongoDB("mongodb://forest:[email protected]:37017",
repositoryName, 16).
setClusterId(123456).
setAsyncDelay(1000).
setBlobStore(dsbs);
DocumentNodeStore docStore = builder.build();
Oak oak = new Oak(docStore);
LuceneIndexProvider luceneProvider = new LuceneIndexProvider();
Jcr jcr = new Jcr(oak)
.with(new LuceneIndexEditorProvider())
.with((QueryIndexProvider) luceneProvider)
.with((Observer) luceneProvider)
.withAsyncIndexing();
Repository repository = jcr.createRepository();
RepositoryImpl repImpl = (RepositoryImpl) repository;
Session session = null;
try {
session = repImpl.login(new SimpleCredentials("admin",
"admin".toCharArray()), null, new HashMap<String, Object>());
Node root = session.getRootNode();
System.out.println(root.getPath());
}
finally {
if(session != null) {
session.logout();
}
repImpl.shutdown();
docStore.dispose();
}
}
My question is: is there another way to "create" the database having 64
characters? or should I establish 63 (or maybe less) as the limit for db
names?
Thanks.
Regards.
Jorge Flórez