Re: Remaining tasklist for alpha?

"Lachezar Dobrev" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Organization LSN Software and telecommunication systems
Message-ID <079c01c3997e$ed6c1b80$6f02a8c0@Sijaiko>
  Did not show for 5 hours... Resending...

  Hi.

> I see.
> This approach seems very like JBoss' ServiceManager:
> one root MBean that starts all other MBeans.
> The ServiceManager MBean has also the notion of dependencies,
> to cycle the life of MBeans (so if I stop an MBean via
> management interface, also the ones that depend on it will be stopped).
  Actually the idea was borrowed from jboss, but mine was quite lightweight.
It did not implement any dependancies, but rather I had many deployer
MBeans, and each would execute the shutdown procedure upon it's
deregistration.

> Also there there is a shutdown hook that calls stop on this
> root MBean.
  Mmmmm... I wouldn't like that. That would fix the Root MBean to be a
"singleton", while my idea was, that the Root MBean is just like other
loaders, but if created/started from the main application method.

> I think this approach requires a lifecycle interface
> with at least start()/stop() methods, so that the root
> MBean can invoke these methods (although
> reflection-style-JMX-invocation allows you to "try" to
> invoke stop() and if there is no stop() method it does not matter).
  Well... I do not think this is quite useful. Of course it will work, and
works, but I would need to perform more complex startup/shutdown procedure,
and this would not be my case.
  A typical problem of mine was, that before invoking operations I needed to
set up Attributes according to my liking (i.e. ports, Jndi names, conf
settings, etc., etc.)
  So I was thinking of a more robust initialization/shutdown procedure, that
will allow invoking arbitrary operations with arbitrary parameters, setting
arbitrary attributes to arbitrary values, etc.
  What about this:
  <mx4j>
    <startup>
      <create object="Domain:prop=blob" type="com.boom.Room">
        <argument type="java.lang.Boolean" value="true" />
        <argument type="java.net.InetAddress" value="127.0.0.1" />
      </create>
      <set object="Domain:prop=blob" attribute="Attrib">
        <argument type="com.boom.RoomAttrImpl" value="BlahBlah" />
      </set>
      <set object="Domain:prop=blob" attribute="TextAttrib">
        <!-- type omitted, taken from attribute type -->
        <argument value="BlahBlah" />
      </set>
      <invoke object="Domain:prop=blob" operation="connect">
        <argument type="com.boom.RoomAddress">
          <argument type="java.lang.String" value="localhost"/>
          <argument type="int" value="1099"/>
        </argument>
      </invoke>
      <invoke object="Domain:prop=blob" operation="start" />
    </startup>
    <shutdown>
      <invoke object="Domain:prop=blob" operation="stop" />
      <invoke object="Domain:prop=blob" operation="disconnect" />
      <unregister object="Domain:prop=blob" />
    </shutdown>
    <!-- optional -->
    <restart>
      <invoke object="Root:type=Logger" operation="info">
        <argument value="Restarting" />
      </invoke>
      <shutdown />
      <invoke object="Root:type=Logger" operation="info">
        <argument value="Shutdown done" />
      </invoke>
      <startup  />
      <invoke object="Root:type=Logger" operation="info">
        <argument value="Startup  done" />
      </invoke>
    </restart>
  </mx4j>


> What I'm often facing is that I would like to start my
> standalone server from a remote shell, and also from a
> remote shell, shut it down (no physical access to
> hardware), and then to close that shell.
> I would like to have a startup.sh script and a shutdown.sh
> script, very much like Tomcat's (which relies on sockets).
  How about... Writing a common Main class with a common main method, that
will require a startup/shutdown script as a parameter? This class can set up
the Shutdown handler, and eventualy (if available in the JVM) interrupt
handlers, that will correctly handle SIG_HUP, SIG_QUIT, SIG_TERM etc. to
perform shutdown or restart?
  How about that?

  One can than do:
  <startup.sh>
    java -cp $CP$ mx4j.startup.Main /home/mx4j/server.mx4j.xml
      &> /home/mx4j/server.mx4j.log &
    echo $! > /home/mx4j/server.mx4j.pid
  </startup.sh>

  <restart.sh>
    kill -HUP `cat /home/mx4j/server.mx4j.pid`
  </restart.sh>

  <shutdown.sh>
    kill `cat /home/mx4j/server.mx4j.pid`
  </shutdown.sh>

  The only thing one needs to do is to create a startup/shutdown script-xml
and voila.


> Instead of sockets I can of course rely on JSR 160, but that
> requires a lot of machinery to be present: the
> RMIConnectorServer and a naming service on 1099, otherwise I
> am reduced to parse JMXConnectorServer output or PIDs, sigh.
  Actually it is a rare case where there are no adapters in the MBean
server... Am I correct?
  However the shutdown script will need to know where and how to find the
MBean server vm, and still we need a shutdown(service) MBean, that will be
called in order to shutdown the server. Right?

> I would like very much to write a startup.xml and a
> shutdown.xml with information on how to start and how to
> stop my server; and a startup.sh and shutdown.sh that feed
> these 2 xml to a configuration loader.
  Well except for the part that I would like the shutdown and startup
procedure in one file I think we speak the same language...

> This is JMX, and still I see no easy way to do this.
>
> Any idea ?
  Mmmmm... Isn't this what the list is for?

> Simon

  Lachezar.






-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.