You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Delos <da...@gmail.com> on 2010/08/17 10:45:07 UTC
How to detect status of server instance?
For some reasons, we often need to know if there is a running server
instance. By establishing a connection to a specific port such as 1099, we
may get the status of server. However, the method doesn't work if default
port number is changed, especially in multi-instances scenario. In
multi-instances scenario, we hope to know if any instance is running.
Below is my thoughts about the solution. Any comments or suggestions, please
feel free to tell me. It will be appreciated if any better solution could be
provided.
Possible solution:
We may create flag file for each instance and lock the file with
FileChannel.lock() when a server instance is starting up. It will be
unlocked and deleted when the server is stopped. Unlocking will be
automatically done when JVM exits; deleting the file can be done in shutdown
hook in FrameworkLauncher.launch().
In this way, if any flag file has been locked, we may deduce that there is
at least one running server instance; if no locked files found, we may think
all server instances are stopped. We can put all the flag files in a same
directory for us to track.
--
Best Regards,
Delos
Re: How to detect status of server instance?
Posted by Jarek Gawor <jg...@gmail.com>.
I'm not sure I understand. You just need to know that some server
instance is running? How is that helpful? You still will need to know
what ports the given server instance is using to actually interact
with it.
What's the actual problem you are trying to address?
Jarek
On Tue, Aug 17, 2010 at 4:45 AM, Delos <da...@gmail.com> wrote:
>
> For some reasons, we often need to know if there is a running server
> instance. By establishing a connection to a specific port such as 1099, we
> may get the status of server. However, the method doesn't work if default
> port number is changed, especially in multi-instances scenario. In
> multi-instances scenario, we hope to know if any instance is running.
> Below is my thoughts about the solution. Any comments or suggestions, please
> feel free to tell me. It will be appreciated if any better solution could be
> provided.
> Possible solution:
>
> We may create flag file for each instance and lock the file with
> FileChannel.lock() when a server instance is starting up. It will be
> unlocked and deleted when the server is stopped. Unlocking will be
> automatically done when JVM exits; deleting the file can be done in shutdown
> hook in FrameworkLauncher.launch().
> In this way, if any flag file has been locked, we may deduce that there is
> at least one running server instance; if no locked files found, we may think
> all server instances are stopped. We can put all the flag files in a same
> directory for us to track.
>
> --
> Best Regards,
>
> Delos
>
Re: [DISCUSSION] How to detect status of server instance?
Posted by Donald Woods <dw...@apache.org>.
Will file locking work across all OS and filesystem combinations
reliably? Wondering about Windows/exFAT and Unix/NFS shares....
Another way is to use *.pid files to hold the server process id or
something like *.rmi or *.jmx files to denote the ports that servers are
listening on.
Maybe building something into the Felix shell to track instances would
be another solution?
-Donald
On 8/17/10 9:37 PM, Delos wrote:
>
> 2010/8/17 Delos <daition@gmail.com <ma...@gmail.com>>
>
>
> For some reasons, we often need to know if there is a running server
> instance. By establishing a connection to a specific port such as
> 1099, we may get the status of server. However, the method doesn't
> work if default port number is changed, especially in
> multi-instances scenario. In multi-instances scenario, we hope to
> know if any instance is running.
>
> Below is my thoughts about the solution. Any comments or
> suggestions, please feel free to tell me. It will be appreciated if
> any better solution could be provided.
>
> Possible solution:
>
> We may create flag file for each instance and lock the file with
> FileChannel.lock() when a server instance is starting up. It will
> be unlocked and deleted when the server is stopped. Unlocking will
> be automatically done when JVM exits; deleting the file can be done
> in shutdown hook in FrameworkLauncher.launch().
>
> In this way, if any flag file has been locked, we may deduce that
> there is at least one running server instance; if no locked files
> found, we may think all server instances are stopped. We can put all
> the flag files in a same directory for us to track.
>
> --
> Best Regards,
>
> Delos
>
>
>
>
> --
> Best Regards,
>
> Delos
[DISCUSSION] How to detect status of server instance?
Posted by Delos <da...@gmail.com>.
2010/8/17 Delos <da...@gmail.com>
>
> For some reasons, we often need to know if there is a running server
> instance. By establishing a connection to a specific port such as 1099, we
> may get the status of server. However, the method doesn't work if default
> port number is changed, especially in multi-instances scenario. In
> multi-instances scenario, we hope to know if any instance is running.
>
> Below is my thoughts about the solution. Any comments or suggestions,
> please feel free to tell me. It will be appreciated if any better solution
> could be provided.
>
> Possible solution:
>
> We may create flag file for each instance and lock the file with
> FileChannel.lock() when a server instance is starting up. It will be
> unlocked and deleted when the server is stopped. Unlocking will be
> automatically done when JVM exits; deleting the file can be done in shutdown
> hook in FrameworkLauncher.launch().
>
> In this way, if any flag file has been locked, we may deduce that there is
> at least one running server instance; if no locked files found, we may think
> all server instances are stopped. We can put all the flag files in a same
> directory for us to track.
>
> --
> Best Regards,
>
> Delos
>
--
Best Regards,
Delos
Re: How to detect status of server instance?
Posted by Delos <da...@gmail.com>.
Thanks David & Kevan!
See my reply in blue.
2010/8/23 Kevan Miller <ke...@gmail.com>
>
> On Aug 19, 2010, at 11:17 PM, David Jencks wrote:
>
> > This isn't enough information for me.
> >
> > What do you want to do with the information that, for instance, a karaf
> instance started but no geronimo bundles were started? You have no idea how
> to contact this karaf instance with this information, nor any information
> about what it can do.
>
> I think we should target our common/intended use cases, which IMO is
> running geronimo *servers*, not karaf instances...
>
I agree running karaf instance doesn't means a geronimo server is
running. My solution only tells status of karaf instance, but it's enough
for me, I think.
>
> >
> > I don't think we should support this. I can understand trying to
> communicate with a server that can do something, but not detecting that a
> jvm started with some stuff running that has no way to communicate with the
> outside world.
> >
> > Maybe if you explain your goals I'll start thinking this might be
> useful....
>
> IIUC, Rex wants to be able to detect running instances of Geronimo servers.
> This could be used by install/uninstall programs or other management tools
> for administering Geronimo servers.
>
> Personally, I'd like to understand what this code would look like. Is a
> patch available?
>
You may find a initial patch of my solution.
http://svn.apache.org/repos/asf/geronimo/sandbox/delos/status.patch
>
> I think our handling of multiple server instances could be improved. Aids
> to help with the creation, configuration, and control of server instances.
> Capturing information about running server instances might help us with some
> of these issues...
>
> Agree.
> --kevan
--
Best Regards,
Delos
Re: How to detect status of server instance?
Posted by Kevan Miller <ke...@gmail.com>.
On Aug 19, 2010, at 11:17 PM, David Jencks wrote:
> This isn't enough information for me.
>
> What do you want to do with the information that, for instance, a karaf instance started but no geronimo bundles were started? You have no idea how to contact this karaf instance with this information, nor any information about what it can do.
I think we should target our common/intended use cases, which IMO is running geronimo *servers*, not karaf instances...
>
> I don't think we should support this. I can understand trying to communicate with a server that can do something, but not detecting that a jvm started with some stuff running that has no way to communicate with the outside world.
>
> Maybe if you explain your goals I'll start thinking this might be useful....
IIUC, Rex wants to be able to detect running instances of Geronimo servers. This could be used by install/uninstall programs or other management tools for administering Geronimo servers.
Personally, I'd like to understand what this code would look like. Is a patch available?
I think our handling of multiple server instances could be improved. Aids to help with the creation, configuration, and control of server instances. Capturing information about running server instances might help us with some of these issues...
--kevan
Re: How to detect status of server instance?
Posted by David Jencks <da...@yahoo.com>.
This isn't enough information for me.
What do you want to do with the information that, for instance, a karaf instance started but no geronimo bundles were started? You have no idea how to contact this karaf instance with this information, nor any information about what it can do.
I don't think we should support this. I can understand trying to communicate with a server that can do something, but not detecting that a jvm started with some stuff running that has no way to communicate with the outside world.
Maybe if you explain your goals I'll start thinking this might be useful....
thanks
david jencks
On Aug 19, 2010, at 8:03 PM, Delos wrote:
> Let me try again to clarify my requirements and implementation.
>
> What I want to do?
> I just hope to detect all running instances of a specific Geronimo installation (For multi instances configuration, see https://cwiki.apache.org/GMOxDOC22/running-multiple-geronimo-instances.html). In one word, I just need a mechanism to tell if any running instance exists or not. So far, I don't care which instance is running but only want to know if there is a running instance.
>
> How I want to do?
> My solution leverages a flag file to indicate if an instance is running. When an instance is running, it will lock its flag file first; any other process or thread CAN'T lock this file any more until the instance is stopped. In this way, by checking if any of these flag files is lockable, we can know if there is a running instance.
>
> Flag file
> A flag file can be created and locked at the beginning when a server instance is starting. The file can also be unlocked and deleted at the ending when the serve instance is stopping. File creating and locking can be done before we start OSGi framework at the beginning of Bootstrapper.execute(); while file deleting and unlocking can be done in the thread added as shutdown hook in FrameworkLauncher.launch() (line 140). NOTE, even if server instance is stopped abnormally, its flag file will still be unlocked by JVM.
>
> API
> It's not difficult to create and delete flag file by File.createNewFile() and File.delete(). For locking and unlocking file, we may use FileChannel.lock() to lock a file, FileChannel.tryLock() to check if the file has been locked and FileLock.release() to unlock the file.
>
> 2010/8/18 Rex Wang <rw...@gmail.com>
>
>
> 2010/8/18 Kevan Miller <ke...@gmail.com>
>
>
> On Aug 17, 2010, at 4:45 AM, Delos wrote:
>
> >
> > For some reasons, we often need to know if there is a running server instance. By establishing a connection to a specific port such as 1099, we may get the status of server. However, the method doesn't work if default port number is changed, especially in multi-instances scenario. In multi-instances scenario, we hope to know if any instance is running.
>
> I think we'd better do a better job of defining some requirements. I'm not sure I understand precisely what you're trying to accomplish. Some off-hand thoughts:
>
> 1) Users want to know when a server is up and running and ready to process user requests (at least that's what users have asked me for, in the past). So, the fact that a process has been started is probably not sufficient
>
> 2) I think most users will want information on a specific server, not *any* server
>
> 3) If determining the proper port to be used is a problem (and I think we should make this simpler), then the problem applies to any command stop-server, wait-for-server, deploy, list-modules, etc.
>
>
>
> wait-for-server might be a good way to address the problem, however it is a gsh command in 2.1.x
> Shall we resume the command in deploytool for 3.0?
>
> -Rex
>
>
> >
> > Below is my thoughts about the solution. Any comments or suggestions, please feel free to tell me. It will be appreciated if any better solution could be provided.
> >
> > Possible solution:
> >
> > We may create flag file for each instance and lock the file with FileChannel.lock() when a server instance is starting up. It will be unlocked and deleted when the server is stopped. Unlocking will be automatically done when JVM exits; deleting the file can be done in shutdown hook in FrameworkLauncher.launch().
> >
> > In this way, if any flag file has been locked, we may deduce that there is at least one running server instance; if no locked files found, we may think all server instances are stopped. We can put all the flag files in a same directory for us to track.
>
> It's been a while since I looked at similar issues, but I'm not very trusting about how much work a Java process can be guaranteed to perform on shutdown. Normal shutdown situations work fine. But what happens when the JVM catches an abnormal signal and just exits? I'd want to see thorough testing of any file locking/file deleting technique (especially if appropriate file manipulation was required to start/restart the server).
>
> --kevan
>
>
>
> --
> Lei Wang (Rex)
> rwonly AT apache.org
>
>
>
> --
> Best Regards,
>
> Delos
Re: How to detect status of server instance?
Posted by Delos <da...@gmail.com>.
Let me try again to clarify my requirements and implementation.
- What I want to do?
I just hope to detect all running instances of a specific Geronimo
installation (For multi instances configuration, see
https://cwiki.apache.org/GMOxDOC22/running-multiple-geronimo-instances.html).
In one word, I just need a mechanism to tell if any running instance exists
or not. So far, I don't care which instance is running but only want to know
if there is a running instance.
- How I want to do?
My solution leverages a flag file to indicate if an instance is running.
When an instance is running, it will lock its flag file first; any other
process or thread CAN'T lock this file any more until the instance is
stopped. In this way, by checking if any of these flag files is lockable, we
can know if there is a running instance.
Flag file
A flag file can be created and locked at the beginning when a server
instance is starting. The file can also be unlocked and deleted at the
ending when the serve instance is stopping. File creating and locking can be
done before we start OSGi framework at the beginning of
Bootstrapper.execute(); while file deleting and unlocking can be done in the
thread added as shutdown hook in FrameworkLauncher.launch() (line 140).
NOTE, even if server instance is stopped abnormally, its flag file will
still be unlocked by JVM.
API
It's not difficult to create and delete flag file by File.createNewFile()
and File.delete(). For locking and unlocking file, we may use
FileChannel.lock() to lock a file, FileChannel.tryLock() to check if the
file has been locked and FileLock.release() to unlock the file.
2010/8/18 Rex Wang <rw...@gmail.com>
>
>
> 2010/8/18 Kevan Miller <ke...@gmail.com>
>
>
>> On Aug 17, 2010, at 4:45 AM, Delos wrote:
>>
>> >
>> > For some reasons, we often need to know if there is a running server
>> instance. By establishing a connection to a specific port such as 1099, we
>> may get the status of server. However, the method doesn't work if default
>> port number is changed, especially in multi-instances scenario. In
>> multi-instances scenario, we hope to know if any instance is running.
>>
>> I think we'd better do a better job of defining some requirements. I'm not
>> sure I understand precisely what you're trying to accomplish. Some off-hand
>> thoughts:
>>
>> 1) Users want to know when a server is up and running and ready to process
>> user requests (at least that's what users have asked me for, in the past).
>> So, the fact that a process has been started is probably not sufficient
>>
>> 2) I think most users will want information on a specific server, not
>> *any* server
>>
>> 3) If determining the proper port to be used is a problem (and I think we
>> should make this simpler), then the problem applies to any command
>> stop-server, wait-for-server, deploy, list-modules, etc.
>>
>>
>
> wait-for-server might be a good way to address the problem, however it is a
> gsh command in 2.1.x
> Shall we resume the command in deploytool for 3.0?
>
> -Rex
>
>
>
>> >
>> > Below is my thoughts about the solution. Any comments or suggestions,
>> please feel free to tell me. It will be appreciated if any better solution
>> could be provided.
>> >
>> > Possible solution:
>> >
>> > We may create flag file for each instance and lock the file with
>> FileChannel.lock() when a server instance is starting up. It will be
>> unlocked and deleted when the server is stopped. Unlocking will be
>> automatically done when JVM exits; deleting the file can be done in shutdown
>> hook in FrameworkLauncher.launch().
>> >
>> > In this way, if any flag file has been locked, we may deduce that there
>> is at least one running server instance; if no locked files found, we may
>> think all server instances are stopped. We can put all the flag files in a
>> same directory for us to track.
>>
>> It's been a while since I looked at similar issues, but I'm not very
>> trusting about how much work a Java process can be guaranteed to perform on
>> shutdown. Normal shutdown situations work fine. But what happens when the
>> JVM catches an abnormal signal and just exits? I'd want to see thorough
>> testing of any file locking/file deleting technique (especially if
>> appropriate file manipulation was required to start/restart the server).
>>
>> --kevan
>
>
>
>
> --
> Lei Wang (Rex)
> rwonly AT apache.org
>
--
Best Regards,
Delos
Re: How to detect status of server instance?
Posted by Rex Wang <rw...@gmail.com>.
2010/8/18 Kevan Miller <ke...@gmail.com>
>
> On Aug 17, 2010, at 4:45 AM, Delos wrote:
>
> >
> > For some reasons, we often need to know if there is a running server
> instance. By establishing a connection to a specific port such as 1099, we
> may get the status of server. However, the method doesn't work if default
> port number is changed, especially in multi-instances scenario. In
> multi-instances scenario, we hope to know if any instance is running.
>
> I think we'd better do a better job of defining some requirements. I'm not
> sure I understand precisely what you're trying to accomplish. Some off-hand
> thoughts:
>
> 1) Users want to know when a server is up and running and ready to process
> user requests (at least that's what users have asked me for, in the past).
> So, the fact that a process has been started is probably not sufficient
>
> 2) I think most users will want information on a specific server, not *any*
> server
>
> 3) If determining the proper port to be used is a problem (and I think we
> should make this simpler), then the problem applies to any command
> stop-server, wait-for-server, deploy, list-modules, etc.
>
>
wait-for-server might be a good way to address the problem, however it is a
gsh command in 2.1.x
Shall we resume the command in deploytool for 3.0?
-Rex
> >
> > Below is my thoughts about the solution. Any comments or suggestions,
> please feel free to tell me. It will be appreciated if any better solution
> could be provided.
> >
> > Possible solution:
> >
> > We may create flag file for each instance and lock the file with
> FileChannel.lock() when a server instance is starting up. It will be
> unlocked and deleted when the server is stopped. Unlocking will be
> automatically done when JVM exits; deleting the file can be done in shutdown
> hook in FrameworkLauncher.launch().
> >
> > In this way, if any flag file has been locked, we may deduce that there
> is at least one running server instance; if no locked files found, we may
> think all server instances are stopped. We can put all the flag files in a
> same directory for us to track.
>
> It's been a while since I looked at similar issues, but I'm not very
> trusting about how much work a Java process can be guaranteed to perform on
> shutdown. Normal shutdown situations work fine. But what happens when the
> JVM catches an abnormal signal and just exits? I'd want to see thorough
> testing of any file locking/file deleting technique (especially if
> appropriate file manipulation was required to start/restart the server).
>
> --kevan
--
Lei Wang (Rex)
rwonly AT apache.org
Re: How to detect status of server instance?
Posted by Kevan Miller <ke...@gmail.com>.
On Aug 17, 2010, at 4:45 AM, Delos wrote:
>
> For some reasons, we often need to know if there is a running server instance. By establishing a connection to a specific port such as 1099, we may get the status of server. However, the method doesn't work if default port number is changed, especially in multi-instances scenario. In multi-instances scenario, we hope to know if any instance is running.
I think we'd better do a better job of defining some requirements. I'm not sure I understand precisely what you're trying to accomplish. Some off-hand thoughts:
1) Users want to know when a server is up and running and ready to process user requests (at least that's what users have asked me for, in the past). So, the fact that a process has been started is probably not sufficient
2) I think most users will want information on a specific server, not *any* server
3) If determining the proper port to be used is a problem (and I think we should make this simpler), then the problem applies to any command stop-server, wait-for-server, deploy, list-modules, etc.
>
> Below is my thoughts about the solution. Any comments or suggestions, please feel free to tell me. It will be appreciated if any better solution could be provided.
>
> Possible solution:
>
> We may create flag file for each instance and lock the file with FileChannel.lock() when a server instance is starting up. It will be unlocked and deleted when the server is stopped. Unlocking will be automatically done when JVM exits; deleting the file can be done in shutdown hook in FrameworkLauncher.launch().
>
> In this way, if any flag file has been locked, we may deduce that there is at least one running server instance; if no locked files found, we may think all server instances are stopped. We can put all the flag files in a same directory for us to track.
It's been a while since I looked at similar issues, but I'm not very trusting about how much work a Java process can be guaranteed to perform on shutdown. Normal shutdown situations work fine. But what happens when the JVM catches an abnormal signal and just exits? I'd want to see thorough testing of any file locking/file deleting technique (especially if appropriate file manipulation was required to start/restart the server).
--kevan