I need to dynamically update property values in different applications residing on different hosts (one host could have multiple different applications deployed). Different application may have different properties to update.
I am thinking about having each application open a thread just to act as a local server. Then use a centralized application to push out updates through sock connection. But is this too complicated? What if the connection is lost, recovery would be a problem.
Since this kind of problem is not really uncommon, I wonder if anyone knows any existing framework or tools to accomplish it in an easier and cleaner way. Of course, it has to work with tomcat.
Related
We maintain our server once a week.
Sometimes, the customer wishes that we change some settings which is already cached in server.
My colleague always write some JSP code to change these settings which are stored in the memory.
Is it a good method to use this kind of methodology?
If our project is not a Web container, which tools can help me?
Usually, in my experience, the server configuration is not stored only in memory of server:
What happens that after a configuration change, the server has been restarted / just went down for some system reason?
What happens if you have more than one instance of the same server to work on (a cluster of servers in other words)?
So, usually, people opt for various "externalized configuration" options that can range from "file-based" configuration + redeploy the whole cluster upon each configuration change, to configuration management servers (like Consul, etc.d, etc). There are also some solutions that came from (and used in) a java world: Apache Zookeeper, Spring cloud config server to name a few, there are others. In addition, sometimes, it's convenient to store the configurations in a database.
Now to your question: If your project is not a web container and you don't care that configuration will "disappear" after a server restart and you're not running a distributed cluster of servers, then, using JSP indeed doesn't seem appropriate in this case.
Maybe you should take a look at JMX - Java management extensions, that have a built-in solution so that you probably will be able to get rid of a web container (which seems to be not used by your team anyway other than for JSP modifications that you've described).
You basically need in memory cache, there are multiple solutions found in answers which include creating your own implementation or using existing java library. You can also get data from database and add cache over the database layer.
We are looking at our current Liferay deployment for improvement in the near future. We'd like to move to where we use instances more.
We currently have a few sites in the default instance. The model we'd like to follow in the future is to - use the default instance for super/global administrator use only. Then create instances with different domains for different audiences/users and that they can be administered by different administrators/groups separately.
Does anyone know how can we move our sites and its related data to another Liferay instance? Is this easy and doable? Are there clearly defined steps and options for this process? Are there any risks to moving the data?
Thanks for the insight.
instances mean that there's nothing shared between the sites. Well, there actually is something: As you're running on the same appserver, so you're sharing all the code, all plugins.
For this reason you might not be as isolated as you want to be. Administration typically is a bit more tricky, as every single instance needs its own virtual host and its own user database (or LDAP connection). The shared plugins might limit you as to what customization you can do with Liferay.
Quite a few times I've seen expectations to "restart" the instance, which seems legit, as a customer is the only one on that instance. However, this quickly leads to accumulated maintenance windows for all instances that are not clearly visible to other customers.
In general you can use site's import and export, e.g. export to a LAR file and import into a new site on a new server in a different instance. You'll find the Import/Export UI in the site administration UI, along with the page administration.
I am a newbie......I have a Java Swing application and it runs great on my machine. I want to access this application from a Server via Citrix. So when I click on the published icon, it would run the main method in the jar file and will enable me to access the application. This application will be able to access a DB in the DB Server.
But I want mutliple users to access the application at the same time and that is where my questions are:
I thought of creating n number of threads available for n number of users (i.e.) I can set a limit on concurrent access. But what will be the entry point.....I mean when I click on the published icon, it means each time the main method will be invoked.
I can think of seperating my User Interface from the Logic layer....but I have no idea how to do it. ofcourse I am following MVC model. My question is in terms of creating multiple instances of the gui each time the application is accessed.
And finally I want to use DB Connection pooling. So, would this mean that I have to create a separate java program that creates this pool and my application will use its datasource?
Can anyone please 'point' me in the right direction? I am not looking for specific ideas but just an idea on how to create this multi user application.
Typically, for a multi-user Swing application you would want to separate the "client" part of the application from the "server" application.
This works as follows:
Each user would get their own running instance of the client application. This can be on their own machine.
The server application is a single instance (or maybe a cluster) that accepts connections from multiple clients and talks to the database
The client applications talk to the server application when they need to access or change data. There are a wide variety of different communication methods you can use.
Optionally, the server application can send notifications to the client (e.g. in situations where data is updated by another client)
You can do without the server application if you are happy to let the clients connect to the same database. This is simpler to set up, but has some downsides:
You need to be much more careful about concurrent access to the database / potential corruption from different clients attempting to alter the same data at the same time.
You need to allow connections to your database, from clients that are potentially untrusted. This is a security risk.
Given that you already have a working application, the second option is probably easier for you to move to. Just be aware of the downsides: the first option is a much better architecture in general.
Looking for opinions on setting Tomcat and apps to read database for app and global variables. We developing an app that will let developers and network techs configure web apps and servers. This idea came about because the developers shouldn't care which servers their apps are on and take away the need of making sure web.xml and context.xml are correct for each environment.
We want to have all the servers,environments, and variables held in a database, our manager app will allow developers a easy way to set app variables and global tomcat variables. This app will also allow Jenkins a place to get parms it needs for deploying and building apps.
Any thoughts? Is there a way or shareware to do this already?
Thanks.
As far as my opinion on it, I think it can be a very good idea for certain deployments. I've worked on projects where we did this just as you suggest: have a set of "environmental variables" (I use the quotes because they're not really sysEnv variables, but just data in a database) stored in a database, and then for each deployment environment we'd get the app to read those and deploy configure itself accordingly.
Another way we've done this is by actually using System Environment variables. This works great with Java, as you have a common API for reading those without caring about the Operating System you're on. This is faster to implement if the number of such variables to set is not very big: no need to have a db installed, no need to create/update its schema for the storage of said variables, just make OS-specific scripts that will configure them on each environment. Another advantage is that this way you can create multiple users on the same machine, each with a different set of values for the variables, and just have your application deployed for a certain user in order to have it work for that set of variables (have users like integration, pre-production, etc).
The disadvantage with the latter is when you have a really big number of variables. In this case, setting up some database instances and creating (one common) script for the schema creation/update and insertion of data might be simpler than creating huge, OS-Specific scripts.
I have multiple clients:
client 1 - 40 users
client 2 - 50 users
client 3 - 60 users
And I have a web application that is supposed to serve all the clients.
The application is deployed into Tomcat. Each client has it's own database.
What I want to implement is the single web application instance which servers all the clients. The client (and the database to connect to) is identified by the context path from the URL.
I.e. I imply the following scenario:
Some user requests the http://mydomain.com/client1/
Tomcat invokes a single instance of my application (no matter which context is requested)
My application processes the rest of the request thinking that it's deployed to /client1 context path, i.e. all redirect or relative URLs should be resolved against http://mydomain.com/client1/
When the client 2 requests the http://mydomain.com/client2/, I want my application (the same instance) now process it just like if it was deployed to /client2 context path.
Is this possible with Tomcat?
Your application has to do this not tomcat. Now you could deploy your application in three new contexts (client1, client2, client3) with slightly different configuration for the database, and if you are careful to use relative URLs (ie don't do things like /images) then you can do this without changes. This is the transparent way of making your application reusable in that your application is unaware of the global picture that you have 3 different instances of itself running. That means you can easily deploy more or more without having to change your application. You just configure a new instance and go. This only requires you don't use absolute URLs to resources. Using ServletContext.getContextPath() and using .. in your CSS, scripts, etc is helpful as well here.
Probably one of the biggest advantages working this way is that your app doesn't care about global concerns. Because its not involved in those decisions you can run 3 instances on one tomcat server, or if one client needs more scaling they can be moved to their own tomcat server easily. By making your app portable it has forced you to deal with how to install your app in any environment. This is a pillar of horizontal scaling which your situation could very much take advantage being you can split your DB data without having to rejoin them (huge advantage). The option you asked about doesn't force you to deal with this so when the time comes to deal with it it will be painful.
The other option is more involved and requires significant changes to your application to handle this. This is by parsing the incoming URL and pulling out the name of the client then using that name to look up in a configuration file for the database that should be used for that client. SpringMVC can handle things like extracting variables from URL paths. Then making sure you render everything back to them so it points to their portion of the URL. This probably would require a lot of the same requirements as the first. You can use absolute URLs for things like javascript, CSS, and images, but URLs to your app would have to be rewritten at runtime so that it is relative to the requesting client. The benefit is that your only load your application once.
Just as an aside, if you host your CSS, Javascript, images on a CDN in production then both of these options must be relative URL aware. Upsides and downsides to using CDNs as well.
While that sounds good it might not be a good thing because all clients use the same version of the app. Also if you bring down a the app to fix client1 to do maintenance it affects all clients. If you think you'll have to do customization per client then this option will get messy quick. Upgrading a single client means all clients must upgrade and depending on your business model this might not be compatible. Furthermore, I'm not entirely sure you'll save a lot of memory either running only a single version of the application because most apps only take up 10MB of code loaded. A vast majority of the memory is in the VM and processing requests, and using a single Tomcat instance means you share the VM. And with 1 or 3 instances running you still have the same number of requests. You might see a difference of 30-100MBs which in todays world is chump change, and all of those other concerns aren't addresses if you choose to save only a couple of MB.
Essentially there are facilities in Tomcat to aid you in doing this (multiple contexts), but its mostly up to your application to handle this especially if its a single instance.