Dynamic configuration management - java

I'm looking for a tool or set of tools to manage configuration both for our scala application stack and other applications, e.g. lighttpd.
I've been thinking of using Apache Zookeeper, but I haven't found anything that looks like a module for lighttpd (and possibly others). I also considered using for example Puppet, but there doesn't seem to be much of a Zookeeper module for it.
Essentially what I'm trying to achieve is to have one service that keeps configuration & that I can reconfigure dynamically and that would propagate to all services, both on and off the JVM.

Honestly, pick one of the Open Source Configuration Management Systems. One interesting choice that have recently appear and is not listed on Wiki is ANSIBLE.
Also, your problem might be one of orchestration, in which case tools like Chef's Knife, Capistrano, Fabric or MCollective are more adequate.
It might even be you want both, of course.
The best choice would be one written in a language you are familiar with. I don't know of any written in Scala, though this blog post is interesting. For programmers, Chef has great attraction, and handles very dynamic configurations well. I know someone who uses it to create/destroy VM instances on-demand, depending on the application load -- try that with Puppet, and you'll cry.
I like Puppet's declarative configuration style, and in particular the fact that it insulates you a lot from the Operating System differences. To Puppet, a Package is a Package, no matter what operating system you are using.
As for "Zookeeper module"... you might find good recipes/modules for these tools online, but you better be prepared to write your own. Do not chose based on the existence of one particular module -- chose based on how comfortable you feel writing them.

Related

Is it possible to demand load jars into a running java process? Are there frameworks for this?

In the attempt to design & implement & test a distributed capabilities system, Remote Promises[1][2][3], bit identical between Squeak & Java, there are shortcomings. I am seeking work-arounds.
With Remote Promises, proxies can change state, which changes the class implementing the proxy. In Squeak this is done with #becomeForward:, while in Java, it requires a secondary proxy, one that can change it's implemention. This does work.
Exceptions should be non-blocking to allow the event loop to continue, yet also display the problem stack for debugging, out of a quarantine. This is good in Squeak but an open issue with Java. I suppose the answer is do all your logging and then close the exception, allowing the event loop to proceed: it is server-style log debugging.
Using a meta repository, it should be possible to demand load consumers of a particular event type. Dynamically load the latest released code into the consumer servers and spread out the load to speed up the throughput. Update the system at runtime for continuous, seemless operations. I suppose the solution here is to build a dynamic jar classLoader system. Are there any examples of this? An Apache project perhaps?
Remote Promises in Squeak
Cryptography in
Squeak
Remote Promises in
Java, called Raven
Use cloud technologies made for that kind of usecases
I would say that in today world, to get the latest version of a code, you don't use a class loader or any advanced capability of your programming langage. You would user likely some kind of cloud service.
That's may be serverless cloud implementation or a container/kubernetes (https://kubernetes.io/) implementation. You can then perfectly when the new release is loaded, control if you want to do Canary, Blue/Green or progressive rollout or even implement your own strategy.
Because it would work with containers, that would be fine whatever the langage be it C++, java, python, shell, Squeak or anything.
That layer would also provide auto scaling of your various services, redundancy and load balancing and distribute the workload on your cluster.
You can go to the next step with gitops. A PR merge in git automatically trigger the load of the new version in production (https://www.weave.works/technologies/gitops/)
Dynamically loading of jars in Java
Still for sure java thanks to its class loaded API allows to load classes dynamically. This is what web servers are doing and several implementations of that do exist like OSGI or check the response of dimo414.
Conclusion
It would seems that the java route make more sense for a generic plugin system like the one of Eclipse (OSGI), and that the containers solution make more sense for a globally distributed system, auto scaling & resiliance in clusters.
Kubernetes scale to thousand of nodes and provides a whole echosystem to deal with distributed system and it can scale and operate any linux or windows process. This is the de-facto standard pushed by Google and used by thousand of companies over the world.
demand load consumers of a particular event type.
This is typically done via the ServiceLoader API. See the AutoService project to simplify working with services.
This may not be what you need; your question is still very broad, and there are many plausible approaches. Searches for [dynamically load jars] finds existing posts like Load jar dynamically at runtime? that may be of interest.

Tools/techniques to Load/Soak test a deployed Java EE application?

I'm quite new to performance testing and am looking to be pointed in the right direction.
I have a Java project which contains two parts, deployed seperately:
A service-broker, published as a webservice; which has service and db wrappers.
A front end, which has a service-broker facade, business logic and a Spring MVC UI.
It is deployed on tomcat, which is running on a fresh install of Windows server 2008.
I need to do basic soak testing on this project, to highlight major memory leaks performance issues.
I've been told SOAP UI is the tool I need to do this.
Now for my questions:
Soap UI (Load UI) is only appropriate as the load-generator for testing the service-broker aspect of the project, right?
What additional tools would be helpful (Something to visualize garbage collection, memory use, heap/stack size etc?)
Can I use Load UI as a load generator for a Spring MVC Front end? If not, what's an appropriate alternative?
Thanks a lot.
Here is my opinions
SoapUI is good enough for microbenchmark test but not good at huge scale of testing. So i recommend to use other load testing tool. LoadUI can be a solution. But i want to recommend nGrinder. I used it, it works very well. Apache Jmeter is common tool. But it is JVM based so Jmeter itself needs a tuning.
To monitoring application during perfomance testing. easiest way is use VisualVM. It can monitor all that u mentioned. But it can show u a data in just Java Virtual machine perspective. I rather to recommend to use APM (Application Performance Monitoring). AppDynamic will be good solution.
About UX testing, big difference is, it needs record and play feature. U can do it by using Load UI. but nGrinder can also cover that by implementing HTTP resquest in coding. (It is a reason why we use such a expensive tools like LoadRunner etc).
I hope this will be useful to u.
Cheers
There are four sets of requirements you need to cover in a tool
Can it exercise my interface (Any HTTP test tool will do this for a web services application)
Can it monitor my infrastructure. Now you are getting into the details of if your underlying OS and Virtual Machine can be monitored in an integrated fashion. Not all tools allow for this and you need to be very explicit as to the level of detail you are interested in.
Will it report appropriate to my requirements and in a way which allows for easier identification of system bottlenecks? This is a mix of objective and subjective items. You have not indicated what level of reporting you need
Does my user community have the skills to use the tool? Get the top three right and miss this one and even a free as in beer tool goes to a negative ROI almost immediately.
It's time to button up the requirements or just hire a firm with a set of tools included to do the job.

Web Platforms - Amount of Control Given between Java vs ASP.Net

I've been doing a lot of research on web platforms (mainly .Net vs Java), and have found that both seem to serve a lot of purposes. What I'd like to know is, does ASP.Net provide enough control, flexibility, and customization in terms of how the server hosts and runs the website, or does Java with, say, Tomcat and Swing or Struts2 offer more flexibility?
Since Tomcat is from Apache, I'd imagine that they implemented the same design and methodology which came from Apache (which I do like). I question whether or not IIS and Windows Server actually provide this sort of thing. Is my assumption correct?
Here's my own personal analysis of a comparison of the two frameworks having worked on .NET for 4 years and Java for around 5 years.
NET has a cookie-cutter like development stack. Java you have a bit more freedom. This can be a positive or a negative depending upon the developer preference. In other words, if you want to do something in .NET there is typically one standard way of doing so. This is not the case with Java where you can choose from a myriad of libraries and/or strategies to complete your task. In my opinion, Java tends to cater to a more skilled community (especially, since almost every major university teaches on Java) that has a bit more confidence and ability when designing/building applications. That is not a generalization of all Java EE vs. .NET developers as I've met equal talents in skill and ability on both platforms, I'm making a generalization of the larger community as a whole. At the end of the day, it is a harder environment to setup and run, but with that comes the added flexibility.
As far as server environments go, you can host Java EE apps on a number of servers (Tomcat, Glassfish/Apache, JBoss, etc..). Most of them open source, so if you're skilled enough, you can dig down into that code and figure out exactly what you're getting and modify it if necessary. This is absolutely not the case with the Microsoft environment. You basically have a windows server running IIS and that's pretty much it. IIS is a decent web hosting tool in my opinion. It's easy to learn the basics, however out of the box it does not have anywhere near the customization and configuration that you can setup with Apache. For example, you have to install Helicon(or some other tool) as an add-on to IIS if you want to create complex Rewrite rules for your site. Rewrite rules are easily implemented in Apache as a standard.
In conclusion, a Java web environment is harder to setup and support, but you'll get that added flexibility with your language and your server environment as you gain more knowledge.
Choosing a platform should be really about your available expertise - your own or whatever resources you (will) have.
If you know the platform you can make it fly. As #iamkrillin stated, I too have yet to hit a roadblock with IIS/.Net platform. This is true whether or not I am hosting the site myself (colo - I own hardware/OS, etc) or via a hosting provider. On Windows hosting though, choose wisely if you host. If you know you need some bare metal access then make sure you get that privilege from whomever you choose to host with. A good practice is to set your application to medium-trust while developing - unless you will go for a dedicated server, this will likely be your hosting provider's application security setting on shared/cloud environments.
As far as routing is concerned (brought up by #GeorgeMcDowd), IIS now has it bolted in, or, if you prefer to do this at the (ASP.Net) application level (instead of IIS), you can do that too (RouteTables). I don't know how complex you envision your routes will be, so I can't tell whether you will run into some limitation either of these options offer.
As far as "standard" or "cookie cutter" is concerned, I'm not actually sure what that means. You have a (massive and growing) .Net base library (from Microsoft). If you need something very specialized (and not offered by the base lib), you can scour Codeplex and other sources (too) for libraries that you can use in your application. If you use Visual Studio, you can use NuGet to do this with a few clicks.
Don't take Microsoft's stewardship of .Net lightly as well. It's consistently being improved, updated by Microsoft.
There is an area where Microsoft is critically lagging though - and that is in mobile. Against Android and IOS and their respective devices, its a tough climb for Windows (phone, Windows 8 tablet, etc.). There are however, tools that allow you to develop in .Net and push to either device. I am only personally beginning to get into that so I cannot say how perfect or disastrous it is.
Just about the only thing left is cost. Its still cheaper to host on non-Windows platforms. If you already have expertise in non-Windows platforms, then its a no-brainer. However, the hosting cost difference shouldn't be your deciding factor if you have a learning curve (that is commonly the hidden cost).
Without a specific example of what you are referring to configuration wise. I feel pretty comforable saying that there are a variety of ways to configure a website and how it is hosted/ran etc from within the IIS control panel. To that end, I have never ran into a situation where I thought "I wish I could do x with my website" and was not able to make IIS do it.

Update Java code during runtime

about a year ago I stumbled across a nice feature in Java that I cannot for the life of me find again.
Through some magic interface it was apparently possible to declare some classes or functions replaceable during runtime.
I found a nice example guide of someone who ran a simple little program that printed a certain message, he then updated the program using a method I cannot remember anymore and all of a sudden the program had replaced that old print function with a new one.
I've tried looking through the Java API to spark my memory as well as googling but without success. Can anyone here help?
Various app containers can do this.
Basically you'd need to reload the class in a new ClassLoader (unless you're talking about doing this under the debugger, in which case there are completely different APIs available).
In my opinion, this kind of thing is rarely worth the hassle: designing everything so that it can be reloaded is considerably harder than designing it so it can be completely restarted in a new process. It's also easier to be sure exactly what code is running if there's only ever one version loaded in the process.
It's a neat thing to be able to demo, but for most applications it's not worth it. All in my opinion, of course :)
Note that one notable exception is the ability to reload web UI layers without restarting the container: that can make life much easier.
The HotSwap technology was added to Java 1.4 and enable class file replacement at run-time. The feature is provide through the redefineClasses method of the instrumentation package. I think you can also do that through the JPDA interface.
Here is also a reference to what I believe is the research paper that describe the HotSwap mechanism first:
Towards Flexible and Safe Technology for Runtime Evolution of Java Language Applications
Otherwise you can use Classloader, as the other mentionned, but it only provides dynamic class loading, not replacement. The same class loaded twice will be considered as two different types. Combined with interface and/or a bit of reflection, it can however provide ways to update the application at run-time.
Here is a reference to an awesome paper about class loader, and there usage:
Dynamic Class Loading in the Java Virtual Machine
I won't expand on whether this is good or bad, because it was not your question, but I think it's great to have support for run-time software evolution -- too bad that JSR-117 never made it!
This is typically the kind of functionality I gladly leave to infrastructure as it is difficult to get right and easy to get wrong. As Jon mentioned above, most applications do not need it and for those that need it infrastructure is available.
Most application servers allow hot deployment nowadays, and equally most application servers are embeddable and allow them to be stripped down to remove features you do not need.
If it mainly for development, you should look a JRebel which provides this functionality transparently. I've heard they are working on a runtime solution, but I do not know if it is ready for primetime yet.
If you are really motivated to get this to work, then consider using OSGi. It has a steep learning curve, but once you grok it, it does most things right and works very well. I found the pax tools a good starting point but the eclipse toolchain also has good support for it.

How should I start when developing a system based on modules or plugins?

I intend to develop a system that is entirely based on modules. The system base should have support for finding out about plugins, starting them up and being able to provide ways for those modules to communicate. Ideally, one should be able to put in new modules and yank out unused modules at will, and modules should be able to use each other's funcionality if it is available.
This system should be used as a basis for simulation systems where a lot of stuff happens in different modules, and other modules might want to do something based on that.
The system I intend to develop is going to be in Java. The way I see it, I intend to have a folder with a subfolder for each module that includes a XML that describes the module with information such as name, maybe which events it might raise, stuff like that. I suppose I might need to write a custom ClassLoader to work this stuff out.
The thing is, I don't know if my idea actually holds any water and, of course, I intend on building a working prototype. However, I never worked on a truly modular system before, and I'm not really sure what is the best way to take on this problem.
Where should I start? Are there common problems and pitfalls that are found while developing this kind of system? How do I make the modules talk with each other while maintaining isolation (i.e, you remove a module and another module that was using it stays sane)? Are there any guides, specifications or articles I can read that could give me some ideas on where to start? It would be better if they were based on Java, but this is not a requirement, as what I'm looking for right now are ideas, not code.
Any feedback is appreciated.
You should definitely look at OSGi. It aims at being the component/plugin mechanism for Java. It allows you to modularize your code (in so-called bundles) and update bundles at runtime. You can also completely hide implementation packages from unwanted access by other bundles, eg. only provide the API.
Eclipse was the first major open-source project to implement and use OSGi, but they didn't fully leverage it (no plugin installations/updates without restarts). If you start from scratch though, it will give you a very good framework for a plugin system.
Apache Felix is a complete open-source implementation (and there are others, such as Eclipse Equinox).
Without getting into great detail, you should be looking at Spring and a familiarization with OSGI or the Eclipse RCP frameworks will also give you some fundamental concepts you will need to keep in mind.
Another option is the ServiceLoader added in Java 1.6.
They are many way to do it but something simple can be by using Reflection. You write in your XML file name of file (that would be a class in reallity). You can than check what type is it and create it back with reflection. The class could have a common Interface that will let you find if the external file/class is really one of your module. Here is some information about Reflexion.
You can also use a precoded framework like this SourceForge onelink text that will give you a first good step to create module/plugin.

Categories

Resources