Singletons across multiple JVMs

I have an EJB application container which is spread across multiple JVMs(something like a clustered EJB container). I am using a Singleton class to hand out 'running serial numbers'. Therefore there is a Singleton class per JVM(which is not very clean but i chose this path in the absence of anything better). Each singleton comes up when it is first invoked within a JVM and reads a starting running number and a pool of numbers from the database. This way multiple Singletons will not step on each other when doling out the serial numbers and there is no need to go back to the database for every request to the 'running serial number'.
Is there some way to do some of the initialization within these Singleton's just ONCE across the multiple instances of the JVM ie. a real Singleton across multiple JVMs?
Thanks
Ramdas

Pranav,
thanks for your suggestions.
the idea of using a Session bean to access a serialized object was one of my design options when i first implemented this, but then i decided against it because of the overhead of having to make an RMI call for every request to the 'running serial number'. The application being written is for a performance benchmark, and the request to the number being done at least once for every transaction, I chose to use Singletons.
It is a clustered EJB container(not like most conatiners), in the sense that a single container is spread across multiple JVMs.
Now if your application is getting clustured
then you have a problem, in that what you can do is
what object you have made put it in JNDI context and
everytime you want to edit it pull it out edit and set
it back. This will act a your singleton object in
clustured environment accross JVM'sI did not fully understand the second part of your solution????
Ramdas

Similar Messages

  • How to share one variable across multiple JVMs?

    Hi,
    How to share one string value across two applications, which are there in two different JVMs.
    Requirement is, If I update one value(static) in first server through jsp, it should update second server static value too apart from first server.
    I am using WebLogic 8.1, is there any MBean to access other application's static value?
    Please suggest!
    Thanks,
    Murthy P

    Welcome User in OTN,
    to make two projects can access its classes you should goto the project property ---> Dependencies then add the other project.
    in your case:
    try to goto you Model project property ----> Dependencies ---> Edit Dependencies .
    you will find your ViewController project. Expand it thin check to Build Output.
    you can make this for ViewContoller project also as:
    goto you ViewContoller project property ----> Dependencies ---> Edit Dependencies .
    you will find your Model project. Expand it thin check to Build Output.
    Sameh Nassar

  • Share a connection pool across multiple jvms

    hi every1,
    we've got several (core)java modules, each running in its own JVM (somtimes even on seperate machines, though on the same LAN) & each module interacts with a DB. we could maintain a seperate connection pool for each module & utilize it to increase the throughput.
    along with these core modules we also have Tomcat which hosts the webbased frontend to our app, ofcourse in which we have implemented a ConnectionPool & use it to access the DB. This GUI-app is also hosted on the same LAN as the core modules & so is the DB server (mysql).
    the question is... is it possible that somehow the core modules could 'use' the connection pool in Tomcat?
    thanks,
    -ksm

    well... its not about backwards or forwards here. in our app both the core & GUI work independently. the GUI is just for the data-load, config etc...
    since we needed to implement a connection pool for our core modules, all i was wondering is that if it would be possible to utilize the already made pool, the on which we made in Tomcat?

  • Ensuring one singleton instance for multiple JVMs

    i am creating a singleton object. But singleton is per JVM (or rather per classloader) right? But i want to ensure only one instance of my singleton even if there are multiple jvms....how can i achieve that?

    javanewbie80 wrote:
    i am creating a singleton object. But singleton is per JVM (or rather per classloader) right? But i want to ensure only one instance of my singleton even if there are multiple jvms....how can i achieve that?You can't.
    Given computers A and B. Neither have any connectivity by any means to the other.
    Install the application on both and run it. There is no way for either application to know about the other thus only one of the following is possible.
    1. Both applications run and create an instance. Then there are two instances and thus it fails.
    2 The application refuses to run. Then there are none and thus it fails
    Other solutions are possible given that some reasonable requirements based on actual business driven needs are presented.

  • Server, Multiple JVMs sources

    Hi,
    i've to create a (web serivce) server application. This application should be ready for clustering or something, if one server isn't fast enough.
    I know already some things abou concurrency in Java. I'm no Java newbie. But i don't know how clustering works.
    Does it depend on the used JVM?
    Or is this for every server (i.e. Tomcat, JBOSS, ...) different?
    What are the requirements in the webservice-layer and in the persistance layer?
    Any good internet pages/PDFs which discusses this?
    Any good books?
    I really hope some can help me here, because it's very important for me.
    Cheers,
    Ingo

    I just re-read the guidelines for a clustered web app over the weekend, so I think I've got things straight. Your application will have to be sensitive to two important issues:
    1) A class which was previously a singleton may now be instantiated in multiple JVMs. The most obvious side effect of this is that the init() method of any servlet will have a different ServletConfig object passed to it for each JVM it is initialized in. As a result, the application context is no longer a valid place to store information, since the change to the application context is not necessarily propagated to the other JVMs. However, context-params will still be available from all JVMs. Another noticable side-effect is that static variables no longer work as expected (since there may be multiple instances of the same class).
    2) The HttpSession object for a given session can only be in existence on one JVM at a time. If the HttpSession needs to migrate to another JVM, then it will be serialized and sent to the other JVM. As a result, adding an object to a session that is not Serializable may result in IllegalArgumentException being thrown. I'm guessing that in the case of a fail-over (node dies unexepectedly) that the HttpSession object is lost.
    Brian

  • Load balancing HTTP requests for an OC4J instance w/multiple JVMs

    Hello everyone,
    I am using OAS 10.1.3.1 and wish to load balance HTTP requests across an OC4J group of one or more OC4J instances, where each like named OC4J instance may have multiple JVMs or it may just have one JVM.
    My mod_oc4j.conf file would contain the following directives :
    Oc4jSelectMethod roundrobin:local
    Oc4jRoutingMode Static
    Oc4JMount /xyz/* xyz
    In the degenerate case, I would like to have an OC4J group with a cluster size of one, and have that one OC4J instance have two or more JVMs. I would like to be able to receive a request within my web application, determine that the JVM that has been sent the request is the wrong JVM to process the request, and then call HttpServletResponse.sendRedirect("/xyz"). Then, when the browser receives the HTTP 302 response and issues the subsequent HTTP request, have that request sent to a different JVM than the previous JVM that issued the sendRedirect().
    What I have seen is that the subsequent request is sent back to the same JVM that issued the sendRedirect(). I also call invalidate() against the HttpSession prior to calling sendRedirect(), but that does not seem to affect the behavior that I see.
    In the full blown case, I would have an OC4J group with a cluster size > 1, and each of those OC4J instances would have at least one JVM. In that case, I wish the sendRedirect() call to allow the subsequent request to be sent to any one of the OC4J instances in the group, and any one of those JVMs within all of those OC4J instances.
    Can anyone verify that my mod_oc4j mount directive is appropriate given the select method and routing mode? What else might I need to do to have a chance to have a different JVM respond to the request that results from a sendRedirect()?
    Thank you,
    Doug

    I should clarify that in the full blown environment, the OC4J instances that form a group will each be housed within a separate OAS instance that resides on its own machine.
    So ideally, a request could be inbound to say OAS instance 1 on machine A, OC4J instance AA, JVM 2, and I need to force a redirect so that the request can actually be serviced by OAS instance 3 on machine C, OC4J instance AA, JVM 1, and I need to be able to call sendRedirect() against an HttpServletResponse from within a JVM until the subsequent request from the browser, Internet Explorer in my case, is serviced by that JVM.
    Thanks,
    Doug

  • Multiple JVM instances

    Dear all,
    I am trying to create multiple JVM instances using createJavaVM(...) but I can't do it. When I try to create the second instance, the function returns an error.
    Does anybody know about getting multiple JVM instances running??
    Thanks in advance,

    Hallo,
    createJavaVM(...) trys to create a JVM in your current
    process, so I am not surprised that you get an error
    the second time round, because there is already a JVM
    in the process. If you want multiple JVMs, each needs
    to be in its own process.
    Why do you want to create more than one JVM in your
    process? The JVM is multithreadable, and you can start
    more than one thread in the JVM. Would that do what
    you want?I need multiple instances because my application needs nearly 2Gb of memory and the maximum heap I get is 1700 Mb. I think with multiple instances, I'll get it.
    Do you know about getting a bigger heap??
    >
    David Singleton
    [email protected]

  • Sharing jar files across multiple web sites

    Dear all,
    We have an applet as part of an embedded device. I wish to share the jar files across multiple devices. i.e. Accessing 192.168.0.1 shouldn't download the jar files again if the same jar files exist in the cache as a result of download from 192.168.0.2. We are having very large applet jar files, hence reducing download times is a top priority. Is there some way to do that ? Will java web start help in this ?
    regards,
    Jay

    generally for avoiding applet downloading again the best solution is to use applet cahing, just add cache_archive in your html code (for full reference please go to the jdk javadoc ). Of course the problem are diffrent ips 192.168.0.1 and 192.168.0.2, applet caching will work ONLY for one ip, when you serv second sever name/diffrent ip client jvm will treat this applet as something new and will download it . The best solution i think is to sever everything on one server page/ip etc, but as you mentioned it is not good solution.
    Well you can make it if you want to serve your big jar file on diffrent ips/severs, How? You should ctreate small certified applet jar , inside it should be code that will download your huge jar file from any location you want and store IT on CLIENT machine, becouse that jar will be certified so applet with file functions will not ask user to accept dialogs etc, so that applet will create locall on client machine little cache were all files that were downloaded will be stored. And again when user will acess your page that small certfied jar file will check if cache folder exist and if inside it is your huge file.
    cheers

  • Sharing an iTunes Library across multiple user account and a network.

    Sharing an iTunes Music Library across multiple user accounts.
    Hello Everybody!
    Firstly, this was designed to be run in Mac OS X 10.4 Tiger. It will not work with earlier versions of Mac OS X! Sorry.
    Here's a handy tip for keeping your hard drive neat and tidy, it also saves space, what in effect will be done is an iTunes music library will be shared amongst multiple users on the same machine. There are advantages and disadvantages to using this method.
    • Firstly I think it might be worthwhile to state the advantages and disadvantages to using this approach.
    The advantages include:
    - Space will be saved, as no duplicate files will occur.
    - The administrator will be able to have complete control over the content of the iTunes library, this may be useful for restricting the content of the Library; particularly for example if computer is being used at and education institution, business or any other sort of institution where things such as explicit content would be less favorable.
    - The machine will not be slowed by the fact that every user has lots of files.
    The disadvantages to this system include.
    - The fact that the account storing the music will have to be logged in, and iTunes will have to be active in that account.
    - If the account housing the music is not active then nobody can use the iTunes library.
    - There is a certain degree of risk present when an administrator account must be continually active.
    - Fast User Switching must be enabled.
    Overview:
    A central account controls all music on the machine/network, this is achieved by storing iTunes files in a public location as opposed to in the user's directory. In effect the system will give all users across the machine/network access to the same music/files without the possibility of files 'doubling up' because two different users like the same types of music. This approach saves valuable disk space in this regard and may therefore prove to be useful in some situations.
    This is a hearty process to undertake, so only follow this tutorial if you're willing to go all the way to the end of it.
    Process:
    Step 1:
    Firstly, we need to organize the host library, I tidied mine up, removing excess playlists, random files, things like that. this will make thing a bit easier in the later stages of this process.
    Once the library is tidied up, move the entire "iTunes" folder from your Home directory to the "//localhost" directory (The Macintosh HD) and ensure that files are on the same level as the "Applications", "Users", "Library" and "System" directories; this will ensure that the files in the library are available to all users on the machine (this also works for networks)
    Optionally you can set the ownership of the folder to the 'administrator' account (the user who will be hosting the library.), you may also like to set the permissions of 'you can' to "Read & Write" (assuming that you are doing this through the user who will host the library); secondly you should set the "Owner" to the administrator who will be hosting the library and set their "access" to "Read & Write" (this will ensure that the administrator has full access to the folder). The final part of this step involves setting access for the "Others" tab to "Read Only" this will ensure that the other users can view but not modify the contents on the folder.
    Overview:
    So far we have done the following steps:
    1. Organized the host library.
    2. Placed the iTunes directory into a 'public' directory so that other users may use it. (this step is essential if you plan on sharing the library across multiple accounts on the same machine. NOTE: this step is only necessary if you are wanting to share you library across multiple accounts on the same machine, if you simply want to share the music across a network, use the iTunes sharing facility.
    3. set ownership and permissions for the iTunes music folder.
    Step 2:
    Currently the administrator is the only user who can use this library, however we will address this soon. In this step we will enable iTunes music sharing in the administrator's account, this will enable other users to access the files in the library.
    If you are not logged in as the administrator, do so; secondly, open iTunes and select "Preferences" from the "iTunes" menu, now click the "Sharing" tab, if "share my library on my local network" is not checked, the radio buttons below this will now become active, you may choose to share the entire libraries contents, or share only selected content.
    Sharing only selected content may be useful if their is explicit content in the library and minors use the network or machine that the library is connected to.
    If you have selected "share entire library" go to Step 3, if you have selected share "share selected playlists" read on.
    After clicking "share selected playlists" you must then select the playlists that you intend to share across your accounts and network. Once you have finished selecting the playlists, click "OK" to save the settings.
    Overview:
    In this step we:
    1. Enabled iTunes sharing in the administrator's account, now, users on the local network may access the iTunes library, however, users on the same machine may not.
    Step 3:
    Now we will enable users on the same machine to access the library on the machine. This is achieved by logging in as each user, opening iTunes, opening iTunes preferences, and clicking "look for shared music". now all users on the machine may also access the library that the administrator controls.
    This in effect will mean that the user will not need to use their user library, it will be provided to them via a pseudo network connection.
    As a secondary measure, I have chosen to write a generic login script that will move any content from the user's "Music/iTunes/iTunes Music" directory to the trash and then empties the user's trash.
    This is done through the use of an Automator Application: this application does the following actions.
    1. Uses the "Finder" action "Get Specified Finder Items"
    1a. The user's "~/Music/iTunes/iTunes Music" folder
    2. Uses the "Finder" action "Get Folder Contents"
    3. Uses the "Finder" action "Move to Trash"
    4. Uses the "Automator" action "Run AppleScript"
    4a. with the following:
    on run {input, parameters}
    tell application "Finder"
    empty trash
    end tell
    return input
    end run
    IMPORTANT: Once the script is adapted to the user account it must be set as a login item. in order to keep the script out of the way i have placed it in the user's "Library" directory, in "Application Support" under "iTunes".
    Overview:
    Here we:
    1. Enabled iTunes sharing in the user accounts on the host machine, in effect allowing all users of the machine to view a single iTunes library.
    2. (Optional) I have created a login application that will remove any content that has been added to user iTunes libraries, this in effect stops other users of the machine from adding music and files to iTunes.
    Step 4:
    If it is not already enabled, open system preferences and enable Fast User Switching in Accounts Options.
    Summary:
    We have shared a single iTunes library across multiple user account, while still allowing for network sharing. This method is designed to save space on machines, particularly those with smaller hard drives.
    I hope that this hint proves to be helpful and I hope everybody will give me feedback on my process.
    regards,
    Pete.
    iBook G4; 60GB Hard Drive, 512MB RAM, Airport Extreme   Mac OS X (10.4.6)   iWork & iLife '06, Adobe CS2, Final Cut Pro. Anything and Everything!!!

    how to share music between different accounts on a single computer

  • How can I display selected tags across multiple e-mail addresses?

    I receive email on a specific topic but via several e-mail addresses. How can I view selected tags where the resulting e-mails span several (7) email addresses. They are all active on my Thunderbird, but as far as I know, I can only display the selected tag on one of them at a time.
    Any assistance greatly appreciated as this is a very big problem for me.
    thanks, Ron75

    This solution does not appear to work across multiple e-mail addresses.
    Perhaps I should have said "work across multiple e-mail address at the same time. I get e-mail on specific topics via several email addresses and wish to view all the tagged emails regardless of which email account in which they reside.
    I could not get this solution to select more than one email account at a time.

  • Sharing one iTunes library across multiple accounts on the same Mac

    Hello, I've poked around at some of the posts dealing with sharing one iTunes music library across multiple accounts on the same Mac but it seems like this can only be done if the libary is moved to a shared folder. I realize this can be done but I was trying to share it the way it is described in a post on Apple support (See link below.). That post seemed to imply that you don't have to move the library from its original location (owned by account A, e.g.), rather just make a couple preference changes in the accounts, use fast user switching and voila. That doesn't seem to work. So my question is this: Is the only way to share one iTunes music library across multiple accounts on the same Mac to move it to a shared folder? I'm running 10.4.8 on an Intel iMac. Thanks in advance!
    http://docs.info.apple.com/article.html?artnum=93195

    After reading this and several other related threads, I am becoming thoroughly confused about all of this. I have a situation similar to the one that pokerpal described in the post dated January 7 at 8:06 pm, except that the music files on my system are located on an external hard drive. Everything else is pretty much the same though - I am the admin user (and the main iTunes user and maintainer) and my girlfriend is a standard user who has no music in her own iTunes library. She can see and listen to and make playlists from and sync her iPod with the music in this library from her account, and I can do the same thing, independent of her, from my account. And if I make a change to information within a song, she doesn't see it, and vice versa, and I understand that. What I don't understand is why when I add a song or an album to the music files by importing a CD or downloading something from the iTunes Music Store, she has no way of knowing that unless I tell her, and then she can add it to her library by using the "Add to Library" function. Is there no way of automatically updating her library files to add the new song(s)? We have almost 15,000 songs and videos in that library, and I don't even want to think about what might have to happen if the answer to my question is "no." Interestingly enough, if I put an update to a Word document in the same exact location (on the hard drive), we can update that and pass it back and forth all day - why is that such a difficult task for iTunes to accomplish?
    Sorry I went on so long, but this has been building up for some time, and none of the solutions I've read about here have really been of any help, so I'm a bit frustrated and, as I said at the beginning, confused.
    iMac G5, MacBook   Mac OS X (10.4.8)  

  • How do you split the print job across multiple printers to shorten the prin

    i
    Can any one you provide some information on below questions.
    Check printing by XML template (XML Publisher).
    1. When printing checks, how do you print the checks from one printer tray and the overflow remittance pages from another printer tray?
    2. When printing a large batch of checks using XML and PDF output, how do you split the print job across multiple printers to shorten the print time?
    I appreciate if you could give some information on above 2 questions.
    Regards,
    Ramarao.

    Probably sould just do them individually.
    How to get all the iWork apps, iPhoto, and iMovie for free on an eligible iPhone or iPad
    http://www.imore.com/how-get-all-iwork-apps-iphoto-and-imovie-free-eligible-ipho ne-or-ipad
    About Free Apple Apps for iOS 7 compatible devices
    http://support.apple.com/kb/HT5913
     Cheers, Tom

  • APO gATP vs R/3 ATP - To check sales order ATP across multiple plants

    Hi There,
    I am trying to evaluate gATP functionality for SD sales orders.
    The primary requirement is to have sales order ATP checking take place across multiple plants.
    E.G.
    Sales order line is entered for qty 100
    60 is available in plant A, 40 is available in plant B
    System checks both plants and creates 2 lines - one for delivery from plant A and one for delivery from plant B
    (we are currently heading down the road of writing ABAP to do this 'multi-plant' check in R/3 but the more complex the requirements get the more interested I am in understanding more about APO/gATP)
    I would like to understand the benefit of implementing APO / gATP as opposed to using standard R/3 ATP and perhaps writing custom ABAP code to search for inventory across multiple plants.
    I would appreciate any insight regarding what is required to setp gATP to perform such checking and any other feedback regarding this issue - especially if you have had to implement something similar at your company.
    I have looked here but not much clear help:
    http://help.sap.com/saphelp_scm50/helpdata/en/26/c2d63b18bc7e7fe10000000a114084/frameset.htm
    Thanks,
    Niall

    Hi Niall
    you are probably looking at RBATP (Rule based ATP). Look at transaction /sapapo/rba04 in APO where you develop your own location and product substitution rules. Going down an ABAP road in R/3 may work short-term but not long-term as the requirements may get more complex.
    Regards
    Srinivas

  • How do I stop games from syncing across multiple devices?

    Hi there,
    My kids all have their own ipads (super big blessing from a grandparent).  My husband and I each have one as well.  We like to play some of the same games, and sometimes the game progress syncs between our devices.  Eg. We like to play Disney's Frozen Free Fall game, and for some reason, my ipad doesn't sync to my husband's.  When my kids asked for the game on their ipads, however, the games automatically synced to my husband's, so I didn't let them keep it (I didn't want them using all his items/lives).
    My kids all like to play Angry Birds Transformers, and with the latest update to that game, their games are all suddenly connected to each other (they all have the same characters, number of gems, etc.).
    How do these games sync (game center, icloud, etc.)?  Does anyone know how to disable the feature so that our games do not sync across multiple devices?  I would like us to not be sharing the same game progress.  We all share one itunes account.
    Thanks so much!
    (If it helps, I have the ipad2, my kids have ipad mini 2's, and my husband has the ipad air.)

    We all share one itunes account.
    This would  be why the syncing occurs. Until a more knowledgeable person comes   by ...
    You can have one, two or three apple id accounts per idevice. Assign a second apple id to all the kids machines. Same or multiple apple ids. depending on how you want the game to act. Does a family account differ?  delete the game from the current apple id.  Install the game on the new apple id ( or apple ids ).
    Look into family sharing:
    https://www.apple.com/icloud/family-sharing/
    Robert

  • Newbie question about setting up iTunes to sync across multiple computers

    Hi,
    Right now I am using iTunes primarily for listening to streaming radio. However in about 2-3 weeks after I move, I am considering importing all my CDs into iTunes.
    So my question is this. What can I do before I start that will make my life easier for syncing my iTunes across multiple computers.
    I don't expect the computers to connect to each via internet but I do have a 4 GB flash disk and 230 GB firewire drive that could be used. And since one of the computers is MacBook Pro, I could use it in target mode I think.
    Thanks.

    Authorization only applies to computers. When you update a device any protected content on the device for which the library is not authorised will be removed. Otherwise no attempt is made to remove content that was added by a now deauthorised library.
    There is a separate scheme permitting up to 10 devices (computers, iPhones, iPad or iPod touches) to be registered for automatic downloads of your purchases with a different mechanism for deregistering devices.
    Once you have a file on your computer you can physically copy it to any other computer in the same way that you would copy any other file like a Word document, put it on a disk, email it if not too large, burn it to DVD, stick it on an external hard drive or move it over a network. You can use Get Info. To tell you where it is now and you can drop it into the library at the other end.
    The user tip shows how to backup the whole library and then update that backup efficiently. Such a backup to a portable drive also provides a possible tool for transporting any content to another computer.
    tt2

Maybe you are looking for

  • Display image in full screen

    Hi everyone, I am a newbie for labview. I just wanna ask you about image display in labview. Now I can display one image in my front panel. I open the file path and display it. First thing I wanna do is that is it possible to display on monitor full

  • Errors in Importing Web Services to Composite Application

    Hi Everyone, I have created a CAF and exposed its operations as Web Services using CE 7.1 EhP1 SP2 platform. Now I would like to import the web services into another CAF project as external service in the same CE AS. The following are the error messa

  • Financial Report w/subreports

    I am creating a Monthly Financial Statement for a client who has 16 departments.  He wants a Cover page, a Balance Sheet, a Consolidated Income Statement, and each Departmental Income Statement.  All is well except I am having trouble bringing in the

  • Methods & Tools in SAP

    Hi, What are the design methods & design tools  in SAP? Thanks, Suz Moderator Message: Search for available information before posting. Edited by: kishan P on Dec 13, 2010 1:21 PM

  • Events imported from Outlook cannot be editted

    We just got a new MBP, and had the Apple Store transfer a PC's Outlook Calendar to iCal. All the events are there, but none can be editted. They seem to have been locked somehow in Outlook, but none of us can figure out how. I'm also going to check i