Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
6.5k views
in Technique[技术] by (71.8m points)

mongodb - why embedded mongo process not stoping by mongodExecutable.stop()?

Embedded mongo started successful with below code,,but not stoping by mongodExecutable.stop(),this suppose to stop the running mongo. what can be the issue, The below code

 public class Test
       {
 private static final String CONNECTION_STRING = "mongodb://%s:%d";

    private static MongodExecutable mongodExecutable;
    ObjectMapper mapper = new ObjectMapper();
    private static MongodProcess mongod = null;
   

    @After
   public void clean() {
        //mongodExecutable.stop();
        if(mongod.isProcessRunning()) {
        //mongod.stopInternal();
        mongodExecutable.stop();
    }}

    @Before
   public void setup() throws Exception {
        String ip = "localhost";
        int port = 27017;
        

        IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION)
            .net(new Net(ip, port, Network.localhostIsIPv6()))
            .build();

        MongodStarter starter = MongodStarter.getDefaultInstance();
        mongodExecutable = starter.prepare(mongodConfig);
        mongod=mongodExecutable.start();
    }

    @Test
    public void testfeature() throws Exception {
         assertEquals(1, 1);
       
        
    }
 }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

3 Replys

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
0 votes
by (100 points)
Hey Dark Blue, To be honest, I really don't know the exact answer 'mangodExecutable.stop' . I am also waiting for the reply....):

0 votes
by (100 points)
When you call mongodExecutable.stop(), the integrated MongoDB process might not terminate for a number of reasons: The procedure may take longer to end than expected: Using mongodExecutable.stop() instructs the integrated MongoDB process to terminate. Nevertheless, if the process is carrying out a time-consuming activity, there may be a wait before it really terminates. When using mongodExecutable.stop(), you might want to add a delay to give the process time to finish before moving on to the next job. Other applications utilizing MongoDB may include: It's possible that other MongoDB-using processes are blocking the embedded process from terminating. When executing mongodExecutable.stop, ensure that all other MongoDB processes have been terminated (). There may be an issue with how it is set up: Examine the integrated MongoDB process' setup options. It's possible that a setting is preventing the process from properly terminating. See if changing the setup parameters fixes the problem. There could be a problem with the MongoDB version: Ensure that the MongoDB version you are using is appropriate for your application. There may be compatibility issues that are preventing the embedded process from stopping correctly. If none of these actions fix the problem, you might want to try stopping the embedded MongoDB process using a different technique or seek more help from the MongoDB documentation or support.

https://apkgameapps.com/action/gta-5-for-android/
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...