You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by Brian Wallis <br...@infomedix.com.au> on 2007/08/27 01:35:28 UTC

stop and restart embedded server (1.0.2)

G'day,
   I'm attempting to build some testcases that use multiple ldap  
servers and want to test failure scenarios.

I am starting up three apacheds instances on different ports and then  
I want to stop and restart them as required for the various test  
scenarios. I cannot work out how to do this. I am using the following  
to stop the servers and it does seem to stop them.

     Hashtable env = new Hashtable();
     env.putAll(new ShutdownConfiguration 
(instanceName).toJndiEnvironment());
     env.put(Context.PROVIDER_URL, "ou=system");
     env.put(Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.directory.server.jndi.ServerContextFactory");
     env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
     env.put(Context.SECURITY_CREDENTIALS, "secret");
     new InitialDirContext(env);

but I cannot work out how to restart the server again.

What I really want to do is just stop it from listening on its port  
and the re-enable it.

thanks,
brian wallis...


Re: stop and restart embedded server (1.0.2)

Posted by Alex Karasulu <ak...@apache.org>.
Hi Brain,

I think the MINA jars should be stable in terms of API changes so you should

be able to do that I think.  Just replace your 1.0.2 MINA jars with the
1.0.3 and
this should work.  If not we're very close to releasing 1.5.1 which is twice
as
fast, bug free and feature rich as ADS 1.0.3.  So I highly recommend
upgrading
to use it.  Although a feature release branch it is very stable.

Alex

On 8/26/07, Brian Wallis <br...@infomedix.com.au> wrote:
>
> OK. Had a search through jira and found DIRSERVER-926 which explains
> that the issue is in the mina component and was fixed in mina-1.0.3.
> Can I just drop in the 1.0.3 mina jars to resolve this problem? (I'll
> try)
>
> thanks,
> brian wallis...
>
> On 27/08/2007, at 10:37 AM, Brian Wallis wrote:
>
> > G'day Alex,
> >   Thanks for that. I have gotten a bit further. Now I get a
> > "Address already in use" when I restart the server. I think I read
> > somewhere that this was a known problem and may be fixed in a later
> > release or there is a patch for it. Do you know if this is so?
> >
> > thanks,
> >
> > brian wallis...
> >
> > On 27/08/2007, at 9:56 AM, Alex Karasulu wrote:
> >> Please take a look at the tearDown() method of the following class
> >> and it's
> >> super class:
> >>
> >>     *http://tinyurl.com/26kttx
> >>
> >> *This should show you how to properly shutdown the server.  There
> >> is no easy
> >> way right now
> >> to programmatically shutdown just the LDAP port without stopping
> >> the whole
> >> server.  There
> >> is a UI you can trigger to be launched if the server is running on
> >> the
> >> console which allows you
> >> to just stop listening on the port.  However this I don't think
> >> really helps
> >> you a lot.  Take a look
> >> at the server-jndi project's ServerContextFactory to see if there
> >> is an
> >> alternative means to hack
> >> the code to do this.
> >>
> >> If you like submit a patch via JIRA and we can review this as a
> >> new feature.
> >>
> >> HTH,
> >> Alex
> >>
> >>
> >> On 8/26/07, Brian Wallis <br...@infomedix.com.au> wrote:
> >>>
> >>>
> >>> G'day,
> >>>    I'm attempting to build some testcases that use multiple ldap
> >>> servers and want to test failure scenarios.
> >>>
> >>> I am starting up three apacheds instances on different ports and
> >>> then
> >>> I want to stop and restart them as required for the various test
> >>> scenarios. I cannot work out how to do this. I am using the
> >>> following
> >>> to stop the servers and it does seem to stop them.
> >>>
> >>>      Hashtable env = new Hashtable();
> >>>      env.putAll(new ShutdownConfiguration
> >>> (instanceName).toJndiEnvironment());
> >>>      env.put(Context.PROVIDER_URL, "ou=system");
> >>>      env.put(Context.INITIAL_CONTEXT_FACTORY,
> >>> "org.apache.directory.server.jndi.ServerContextFactory");
> >>>      env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
> >>>      env.put(Context.SECURITY_CREDENTIALS, "secret");
> >>>      new InitialDirContext(env);
> >>>
> >>> but I cannot work out how to restart the server again.
> >>>
> >>> What I really want to do is just stop it from listening on its port
> >>> and the re-enable it.
> >>>
> >>> thanks,
> >>> brian wallis...
> >>>
> >>>
> >
>
>

Re: stop and restart embedded server (1.0.2)

Posted by Brian Wallis <br...@infomedix.com.au>.
OK. Had a search through jira and found DIRSERVER-926 which explains  
that the issue is in the mina component and was fixed in mina-1.0.3.  
Can I just drop in the 1.0.3 mina jars to resolve this problem? (I'll  
try)

thanks,
brian wallis...

On 27/08/2007, at 10:37 AM, Brian Wallis wrote:

> G'day Alex,
>   Thanks for that. I have gotten a bit further. Now I get a  
> "Address already in use" when I restart the server. I think I read  
> somewhere that this was a known problem and may be fixed in a later  
> release or there is a patch for it. Do you know if this is so?
>
> thanks,
>
> brian wallis...
>
> On 27/08/2007, at 9:56 AM, Alex Karasulu wrote:
>> Please take a look at the tearDown() method of the following class  
>> and it's
>> super class:
>>
>>     *http://tinyurl.com/26kttx
>>
>> *This should show you how to properly shutdown the server.  There  
>> is no easy
>> way right now
>> to programmatically shutdown just the LDAP port without stopping  
>> the whole
>> server.  There
>> is a UI you can trigger to be launched if the server is running on  
>> the
>> console which allows you
>> to just stop listening on the port.  However this I don't think  
>> really helps
>> you a lot.  Take a look
>> at the server-jndi project's ServerContextFactory to see if there  
>> is an
>> alternative means to hack
>> the code to do this.
>>
>> If you like submit a patch via JIRA and we can review this as a  
>> new feature.
>>
>> HTH,
>> Alex
>>
>>
>> On 8/26/07, Brian Wallis <br...@infomedix.com.au> wrote:
>>>
>>>
>>> G'day,
>>>    I'm attempting to build some testcases that use multiple ldap
>>> servers and want to test failure scenarios.
>>>
>>> I am starting up three apacheds instances on different ports and  
>>> then
>>> I want to stop and restart them as required for the various test
>>> scenarios. I cannot work out how to do this. I am using the  
>>> following
>>> to stop the servers and it does seem to stop them.
>>>
>>>      Hashtable env = new Hashtable();
>>>      env.putAll(new ShutdownConfiguration
>>> (instanceName).toJndiEnvironment());
>>>      env.put(Context.PROVIDER_URL, "ou=system");
>>>      env.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.apache.directory.server.jndi.ServerContextFactory");
>>>      env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>>>      env.put(Context.SECURITY_CREDENTIALS, "secret");
>>>      new InitialDirContext(env);
>>>
>>> but I cannot work out how to restart the server again.
>>>
>>> What I really want to do is just stop it from listening on its port
>>> and the re-enable it.
>>>
>>> thanks,
>>> brian wallis...
>>>
>>>
>


Re: stop and restart embedded server (1.0.2)

Posted by Brian Wallis <br...@infomedix.com.au>.
G'day Alex,
   Thanks for that. I have gotten a bit further. Now I get a "Address  
already in use" when I restart the server. I think I read somewhere  
that this was a known problem and may be fixed in a later release or  
there is a patch for it. Do you know if this is so?

thanks,

brian wallis...

On 27/08/2007, at 9:56 AM, Alex Karasulu wrote:
> Please take a look at the tearDown() method of the following class  
> and it's
> super class:
>
>     *http://tinyurl.com/26kttx
>
> *This should show you how to properly shutdown the server.  There  
> is no easy
> way right now
> to programmatically shutdown just the LDAP port without stopping  
> the whole
> server.  There
> is a UI you can trigger to be launched if the server is running on the
> console which allows you
> to just stop listening on the port.  However this I don't think  
> really helps
> you a lot.  Take a look
> at the server-jndi project's ServerContextFactory to see if there  
> is an
> alternative means to hack
> the code to do this.
>
> If you like submit a patch via JIRA and we can review this as a new  
> feature.
>
> HTH,
> Alex
>
>
> On 8/26/07, Brian Wallis <br...@infomedix.com.au> wrote:
>>
>>
>> G'day,
>>    I'm attempting to build some testcases that use multiple ldap
>> servers and want to test failure scenarios.
>>
>> I am starting up three apacheds instances on different ports and then
>> I want to stop and restart them as required for the various test
>> scenarios. I cannot work out how to do this. I am using the following
>> to stop the servers and it does seem to stop them.
>>
>>      Hashtable env = new Hashtable();
>>      env.putAll(new ShutdownConfiguration
>> (instanceName).toJndiEnvironment());
>>      env.put(Context.PROVIDER_URL, "ou=system");
>>      env.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.directory.server.jndi.ServerContextFactory");
>>      env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>>      env.put(Context.SECURITY_CREDENTIALS, "secret");
>>      new InitialDirContext(env);
>>
>> but I cannot work out how to restart the server again.
>>
>> What I really want to do is just stop it from listening on its port
>> and the re-enable it.
>>
>> thanks,
>> brian wallis...
>>
>>


Re: stop and restart embedded server (1.0.2)

Posted by Alex Karasulu <ak...@apache.org>.
Hi Brain,

Please take a look at the tearDown() method of the following class and it's
super class:

    *http://tinyurl.com/26kttx

*This should show you how to properly shutdown the server.  There is no easy
way right now
to programmatically shutdown just the LDAP port without stopping the whole
server.  There
is a UI you can trigger to be launched if the server is running on the
console which allows you
to just stop listening on the port.  However this I don't think really helps
you a lot.  Take a look
at the server-jndi project's ServerContextFactory to see if there is an
alternative means to hack
the code to do this.

If you like submit a patch via JIRA and we can review this as a new feature.

HTH,
Alex


On 8/26/07, Brian Wallis <br...@infomedix.com.au> wrote:
>
>
> G'day,
>    I'm attempting to build some testcases that use multiple ldap
> servers and want to test failure scenarios.
>
> I am starting up three apacheds instances on different ports and then
> I want to stop and restart them as required for the various test
> scenarios. I cannot work out how to do this. I am using the following
> to stop the servers and it does seem to stop them.
>
>      Hashtable env = new Hashtable();
>      env.putAll(new ShutdownConfiguration
> (instanceName).toJndiEnvironment());
>      env.put(Context.PROVIDER_URL, "ou=system");
>      env.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.directory.server.jndi.ServerContextFactory");
>      env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>      env.put(Context.SECURITY_CREDENTIALS, "secret");
>      new InitialDirContext(env);
>
> but I cannot work out how to restart the server again.
>
> What I really want to do is just stop it from listening on its port
> and the re-enable it.
>
> thanks,
> brian wallis...
>
>

Re: stop and restart embedded server (1.0.2)

Posted by Brian Wallis <br...@infomedix.com.au>.
On 27/08/2007, at 9:35 AM, Brian Wallis wrote:
>
> I am starting up three apacheds instances on different ports and  
> then I want to stop and restart them as required for the various  
> test scenarios. I cannot work out how to do this. I am using the  
> following to stop the servers and it does seem to stop them.
>
>     Hashtable env = new Hashtable();
>     env.putAll(new ShutdownConfiguration 
> (instanceName).toJndiEnvironment());
>     env.put(Context.PROVIDER_URL, "ou=system");
>     env.put(Context.INITIAL_CONTEXT_FACTORY,  
> "org.apache.directory.server.jndi.ServerContextFactory");
>     env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>     env.put(Context.SECURITY_CREDENTIALS, "secret");
>     new InitialDirContext(env);
>
> but I cannot work out how to restart the server again.

I have discovered now that if I start three embedded servers (and  
test them, all respond OK on their associated ldap ports) and then  
shutdown the last one I started using the above code it stops all  
three of them which is not quite what I was expecting. The above code  
seems to stop listening on all three ports not just the one started  
with the name in 'instanceName'.

I think I'm missing something here.

The startup code is like this: (some bits deleted that load an ldif  
file and create a new partition)


    instanceName = "instance_" + port;
    MutableServerStartupConfiguration configuration = new
            MutableServerStartupConfiguration(instanceName);
    workingDir = new File(System.getProperty("java.io.tmpdir") +
            configuration.getWorkingDirectory().getPath() + "." + port);
    configuration.setWorkingDirectory(workingDir);
    doDelete(configuration.getWorkingDirectory()); // cleanup before  
starting

    configuration.setLdapPort(port);
    configuration.setEnableNetworking(true);
    configuration.setShutdownHookEnabled(false);
    configuration.setAllowAnonymousAccess(false);
    configuration.setAccessControlEnabled(false);
    configuration.setEnableChangePassword(false);
// ...
// create new partitions and load ldif file
// ....
	Hashtable env = new Hashtable(configuration.toJndiEnvironment());
    env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
    env.put(Context.SECURITY_CREDENTIALS, "secret");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.INITIAL_CONTEXT_FACTORY,  
ServerContextFactory.class.getName());
    env.put(Context.PROVIDER_URL, "ou=system");
    sysRoot = new InitialLdapContext(envFinal, null);
    env.put(Context.PROVIDER_URL, "");
    rootDSE = new InitialLdapContext(envFinal, null);