473,748 Members | 4,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing singletons from multiple JVMs?


I've been reading 'Java RMI' from O'Reilly, and it provides a nice
example of scaling a server application by creating multiple instances
of server objects on several distinct machines (each running their own
JVM), and directing clients to the appropriate server through the naming
registry. However, it doesn't really get into how those servers might
talk to each other, except through similar calls through the registry.

For example, suppose I have a Logger class that in a non-RMI application
would be accessed as a singleton and write log requests to a log file.
A class would simply get a refrence to it via the static getInstance()
method and invoke it's other methods directly. Is there a way to get
similar functionality in an environment where I'm using several JVMs on
several machines all connected by a fast LAN? Or is it best to expose
this logger through the RMI registry as well?

Thanks

Mark McKay
--
http://www.kitfox.com

Jul 17 '05 #1
1 7236
Hi Mark-

That's a good question - distributed logging can be a difficult nut to
crack. Here's my two cents on the topic:

The driving factor is managability. If you have N servers, each
generating local logs, your application is not managable. In other words,
it becomes increasingly difficult to locate a log entry for a trouble
ticket the more servers you add into your system. This is not a positive
characteristic.

That being said, you need some form of distributed logging facility. RMI
would work well for you because each local system can remotely connect to
a central server and invoke a method like log(String message). Ultimately
every log message will reside on some media (disk or db) on the central
host. But what happens if that central host goes down?

I believe the best thing for you to do would be to log to a centralized
database (assuming you have a database in your application to begin with -
which may not be a valid assumption). Each node in your application
cluster logs directly to the database without consulting a central host.
This not only reduces network traffic, but more importantly eliminates a
network dependency on an application server running.

Sure, the nay-sayers out there may suggest that you're swapping one
negative for another (no application server running versus not database
running), but I'd argue that if an application server in your cluster
fails it's no big deal. If your entire database tier fails, you're out of
business until you get it running. That being said, depend on the DB to
be there, and make use of it for distributed and concurrent access.
Good luck,
-c

On Tue, 23 Sep 2003 21:24:52 -0700, Mark McKay wrote:

I've been reading 'Java RMI' from O'Reilly, and it provides a nice
example of scaling a server application by creating multiple instances
of server objects on several distinct machines (each running their own
JVM), and directing clients to the appropriate server through the naming
registry. However, it doesn't really get into how those servers might
talk to each other, except through similar calls through the registry.

For example, suppose I have a Logger class that in a non-RMI application
would be accessed as a singleton and write log requests to a log file.
A class would simply get a refrence to it via the static getInstance()
method and invoke it's other methods directly. Is there a way to get
similar functionality in an environment where I'm using several JVMs on
several machines all connected by a fast LAN? Or is it best to expose
this logger through the RMI registry as well?

Thanks

Mark McKay
--
http://www.kitfox.com


Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7796
by: Naresh Agarwal | last post by:
Hi What are the different kinds of JVMs exist and in what respect do they differ. What is the difference between client, server, classic and hotspot jvms? thanks, Naresh
4
3222
by: John | last post by:
Hi, I am pretty new to java and have installed tomcat on my PC (XP Home) along with a few other java tools. I've noticed when I start tomcat ZoneAlarm asks permission for java.exe to access the internet, then if java.exe can be a server. This is obviously tomcat so I say yes. But occassionally I will get a message asking if java.exe can access the internet or act as a server and I don't know why! Is there anyway to tell what is...
8
5266
by: Rahul | last post by:
Hi. I am part of a group in my univ where we organize a programming contest. In this contest we have a UDP based server. The server simulates a game and each contestant is to develop a team of virtual players. Each team is composed of 75 similar bots...i.e. governed by the same logic. Thus the contestant submits a single copy of the client and we instantiate the same program 75 times at the same time. The problem is that while executables...
8
4449
by: 6tc1 | last post by:
Hi all, I'm having a problem where in my solution that contains multiple projects - I instantiate a singleton class in one assembly and then if another assembly tries to use that singleton class another instance of it is created. Basically: --Assembly 1 (the executable)-- -Main.cs-
11
2358
by: John Fly | last post by:
I'm working on a large project(from scratch). The program is essentially a data file processor, the overall view is this: A data file is read in, validated and stored in a memory structure similar to a database or XML representation. Rules to modify the stored data will be executed, then the data will be transformed into an output format. Think something similar to FormatA -> XML -> Manipulate XML -> FormatB
5
1494
by: Omega | last post by:
I'm interested in seeing a bit of discussion about using singletons in ASP.NET 2.0. Currently I've designed a singleton that gets a reference to it's single instance stored inside the ASP.NET application object. This is done to persist and make available live information across multiple sessions. I've read a little bit (almost nothing) about how singletons don't play nicely in clustered scenarios and would like to hear more on the
12
3116
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is only ever ONE instantiation of this class, and this outside method in a separate thread has to access it. How do i do this?
7
1808
by: adam.timberlake | last post by:
I was reading an article on TalkPHP (http://www.talkphp.com/ showthread.php?t=1304) about singletons but I'm afraid I don't understand why I need to use them. I understand how to code them perfectly, it's just the theory I'm having some problems with. I did try searching on Wikipedia but it didn't yield any satisfactory reasoning, for me. Could someone explain it to me in basic terms, please. I initially came across singletons when I...
12
1427
by: Craig Allen | last post by:
Hey, forgive me for just diving in, but I have a question I was thinking of asking on another list but it really is a general question so let me ask it here. It's about how to approach making singletons. Background: I've been programming in python seriously for about a year now, maybe a little longer depending how you count, and the system I am making is sophisticated enough that I've had to enter into a few idioms which were beyond my...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.