0

我正在使用 MongoDB 来存储数据。在我的项目中,我使用线程池将多个用户(100-2000 个用户)连接到服务器,并将这些用户的响应存储在数据库中。但是当我这样做时,我得到了这个错误。请帮我解决一下这个。我无法得到它。我已经在这个错误上浪费了 45 个小时。

错误:

java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.avaya.onex.hss.requesthandlers.CommandExecutor.executeCommands(CommandExecutor.java:129)
    at com.avaya.onex.hss.requesthandlers.CommandExecutor.run(CommandExecutor.java:59)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection
    at com.mongodb.DBPortPool.get(DBPortPool.java:176)
    at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:370)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:149)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:138)
    at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:261)
    at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:211)
    at com.mongodb.DBCollection.insert(DBCollection.java:57)
    at com.mongodb.DBCollection.insert(DBCollection.java:102)
    at com.avaya.onex.hss.objects.LoginRequest.storeData(LoginRequest.java:152)
    at com.avaya.onex.hss.requesthandlers.LoginHandler.handleRequest(LoginHandler.java:20)
    ... 8 more
com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection
    at com.mongodb.DBPortPool.get(DBPortPool.java:176)
    at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:370)
    at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:212)
    at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
    at com.mongodb.DB.command(DB.java:160)
    at com.mongodb.DB.command(DB.java:183)
    at com.mongodb.DB.command(DB.java:144)
    at com.mongodb.DBCollection.drop(DBCollection.java:777)
    at com.mongodb.DBApiLayer$MyCollection.drop(DBApiLayer.java:206)
    at com.avaya.onex.hss.requesthandlers.CommandExecutor.executeCommands(CommandExecutor.java:118)
    at com.avaya.onex.hss.requesthandlers.CommandExecutor.run(CommandExecutor.java:59)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
4

1 回答 1

2

尝试增加连接池中的连接数。

这里,在connectionsPerHost。

于 2012-06-18T11:10:03.727 回答