Core Java

Reasons Why Solaris Is a Great Java Development Platform

Some days ago I posted “The Death of OpenSolaris: Choosing an OS for a Java Developer” in which I stated that Solaris is a great platform for a Java developer. The point of that post was simply wondering about which Solaris version I’d use since the demise of OpenSolaris. What the post did fail in clarifying, as Neil’s comment made me realize, were the reasons why you should choose Solaris as your development platforms. 
I decided to write this follow up to that post to quickly summarize my favorite ones introducing some use cases where such technologies come in handy.

Software Availability
Although Solaris continues to be a niche OS (such as many other platforms are, anyway) in the last few years Sun and the community made an excellent job at promoting it as a desktop alternative for developers. There existed even a specific distribution for developers: Solaris Express Developer Edition. It was discontinued and there really is no need for it nowadays, anyway. Late Solaris distributions (such as SXCE, OpenSolaris, OpenIndiana), include (either bundled or in the official package repository):

  • Data bases (MySQL, PostgreSQL).
  • Web Servers (Apache, Java Enterprise System Web Server, etc.).
  • Application servers (Glassfish).
  • The SAMP stack (Solaris + Apache + MySQL + PHP).
  • IDEs (NetBeans, Eclipse).
  • Support for other popular languages (Ruby, Groovy, etc.).
  • Identity management (LDAP, Java Enterprise System Identity Server).

Solaris also is a platform of choice in the enterprise hence common enterprise software packages are supported and you, as a Java developer or Java architect, won’t miss the pieces you need to build your development environment. The very basic software packages I often need as a Java developers are:

  • Oracle RDBMS.
  • Oracle WebLogic Application Server.
  • IBM WebSphere Application Server.
  • JBoss Application Server.

Solaris’ Technologies

Solaris has got some unique technologies that other UNIX (and UNIX-like) systems that might be used as development platforms are lacking (or ported from Solaris.) What’s important here is not “technologies on their own” or technologies that are helpful only in big enterprise environments, but the fact that:

  • They’re pretty well integrated in Solaris and are built to take advantage of each other.
  • There are common use cases in which these technologies are really helpful to a developer.

Each one of them would deserve several posts on their own, however, I’ll try to make some concise examples.

Solaris Service Management Facility

Although this technology is probably most useful to a system administrator, as a developer I often took advantage of it. SMF is a framework that provides a unified model for services and services management. The basic recipe only needs an XML descriptor for a service. SMF lets you:

  • Define a service: startup scripts location, parameters and semantics.
  • Establish dependencies between services:
    • Services and service instances may depend on other service instances.
    • Service startup is preformed in parallel respecting service dependencies.
  • Enhanced security and fine-grained role based access control:
    • A service can be assigned only the minimum required set of privileges it needs to run.
    • Service management can be delegated to non-root users using Solaris RBAC (Role-Based Access Control).
  • Service health control:
    • Service auto-restarts.
    • Service health is enhanced by cooperation with Solaris Fault Manager which prevents service degradation when hardware failures occur.
  • Automatic inetd Services Wrapper: SMF automatically wraps inetd services.

A Typical Use Case

Every software package I use has its own SMF descriptor (either provided with the package or defined by me) and it dramatically reduces the time I need to set up a development machine. In the case of WebSphere Application Server, for example, I have separate service instances for:

  • WebSphere IHS.
  • WebSphere Application Server.
  • WebSphere Application Server DMGR.
  • WebSphere Application Server cluster nodes.

Dependencies are defined between them and I can startup the required WebSphere services with just a line of code:

svcadm enable [websphere-service-name]

and SMF will take care of everything.

The usage pattern for SMF can be enhanced further. Let’s suppose you’re working in one or more projects and each one of them requires distinct set of running services. What usually happens is one of the following:

  • You install them all and let them run.
  • You install them all and start and stop them manually when you switch working project.

Resources are always few for a developers and some are paranoid about sparing them. With SMF you can:

  • Define a SMF service for each of your projects.
  • For every projects, define dependencies with the services you need.

This way, at a minimum, you can start and shutdown, with a single command, every service you need for a specific project. No more:

  • Custom shell scripts for every service.
  • Custom configuration entries for inetd services (such as Subversion, Apache, etc.)
  • Specific OS customization.
  • Running services when you don’t need them and waste resources you could use otherwise.

Example of SMF service manifest customization can be found in the following posts:

ZFS

The ZFS filesystem is unique as far as it concerns flexibility and ease of use. With an incredibly lean set of commands, you can:

  • Create file systems on the fly.
  • Snapshot file systems on the fly.
  • Clone file system on the fly with almost null space usage overhead.

There’s a huge literature about ZFS and I’ll limit to describe my favorite use cases.

Use case: Multiplexing Your Development Environment.

Software installations are just the beginning of your user experience. Often, we spend time:

  • Configuring our environments.
  • Fine-tuning them.
  • Defining the set of additional libraries we need.
  • Defining the set of server resources (JDBC, JMS, etc.) our applications use.

And so on. The list is endless.

Sometimes it’s necessary to prepare different environments for different projects or different development stages of the same application. Instead of losing time and resource to build different environments I’ll usually proceed as follows:

  • Install and configure my environment.
  • Make a ZFS snapshot of it.
  • Make a ZFS clone of it for every additional setup I need.

Oracle JDeveloper is a good example of an application I often clone. JDeveloper is fundamentally a single user environment, despite adopting the common approach of using a per-user configuration directory in the user’s home directory. Instead of fiddling with scripts to set per-user configuration parameters, I just install it once, snapshot it’s installation directory and make a ZFS clone, one per environment. I use several clones of the JDeveloper environment myself, in my user home directory.

The power of ZFS clones can be used by the Zones infrastructure, as we’ll see in the following section, thus enhancing further its power. Cloning a ZFS filesystem is also advantageous while dealing with big installations such as disk images of your favorite virtualization technologies.

Additional posts I wrote about ZFS that could clarify some of its use cases are:

Containers and Other Virtualization Technologies

I consider Solaris a superior desktop virtualization platform. Once again, with a couple of commands. you can easily create a paravirtualized Solaris instance (a Zone). The zones infrastructure is ZFS-aware and can take advantage of it.

Zones can be configured with a command line interface to its XML configuration file. Creating a zone is straightforward and, since they’re a lightweight technology, you can create as much zones as you need. If you’re using ZFS, the process of cloning a zone is incredibly simple and fast.

Use Case: Clustering an Application Server

During the development of your Java EE application you will tipically need an instance of one (or more) of the following:

  • An application server.
  • A web server.
  • A data base;
  • An user registry.

It’s also desirable to have them running on isolated environments so that you can mimic the expected production configuration. With zones it’s easy: just create as many zones as you need and each one of them will behave as a separate Solaris instance: every zone will have, for example:

  • Its own network card(s) and IP configuration.
  • Its own users, groups, roles and security policies.
  • Its own services.

Instead of installing and configuring an environment multiple times, you will prepare “master” zones with the services you need. I’ve got a “master” zone for every one of the following:

  • WebSphere Application Server.
  • WebLogic Application Server.
  • Oracle DB.
  • MySQL DB.
  • LDAP directory.

and so forth. With one simple command (zoneadm clone [-m copy] [-s zfs_snapshot] source_zone) you’ll end up with a brand new working environment in a question of minutes.

Use Case: VirtualBox and ZFS

Sometimes you’ll rather work on a virtualized instance of some other OS, such as GNU/Linux, FreeBSD and Windows. Solaris is a great VirtualBox host and the power of ZFS will let you:

  • Create “master” images for every OS or every “OS role” you need.
  • Clone them on the fly to create a brand new virtual OS image.

In my case, I’ve got:

  • A master Windows 7 client with Visual Studio for .NET development.
  • A master Windows Server 2008.
  • A master Windows Server 2008 (a clone of the previous one) with SQL Server 2008.
  • A master Debian GNU/Linux.

Every time I need a new instance I just have to clone the disk image. In a matter of seconds I’ve got the environment I need. Not only I’m sparing precious time, I’m also sparing a vast amount of disk space. Should I store all of the images (and zones) I use without the ZFS technology and I’d need at least 4 times as much disks as I’ve got.

Use Case: A Virtualized Network Stack

Solaris provides you pretty powerful network virtualization capabilities. You can, for example, create as many virtual NICs as you need and use them independently either in Solaris Zones or as network cards for other virtualization technologies (such as VirtualBox.) Network cards can be interconnected with virtual switch (etherstubs) and enable you to create “networks in a box.” Not only you can use virtualized instances to mimic your production environment: you’ll be able to create a virtualized network to emulate the complex network policies your environment could need.

If you need to test an environment whose configuration would be impossible to replicate without additional physical machines, that’s where virtualization technologies (such as Zones or VirtualBox) and the virtualized network stack come in handy. My developer environment for a project I’m working for is made up of:

  • Two zones with two load balanced IBM IHS instances.
  • A zone with an LDAP directory.
  • Two zones with two clustered instances of IBM WebSphere Application Server.
  • A Zone with an instance of IBM WebSphere DMGR.

With Solaris, I can replicate the production environment in my box and respect each and every network configuration we use. Without these technologies, it would have been much harder to accomplish this goal or I would end up with custom configurations (for example, to avoid port clashes). In all cases, I’d lose much more time on the administration and configuration of such environments if zones weren’t so easy to use.

DTrace

DTrace power is extremely easy to explain to a developer. At the same time, it’s difficult to grasp its usefulness without trying it yourself. DTrace on Solaris provides tens of thousand of probes out of the box and others can be created on the fly. This “probes” provide you an extremely powerful mean of troubleshoot problems in either your applications and the underlying operating systems. To use the probes you’ve got to use scripts written in the D language. Fortunately, this language is pretty easy by design and you can write powerful D scripts in a few lines of code.

DTrace is unobtrusive and let you troubleshoot problems immediately, without modifying your application, even in a production environment. Some IDEs, such as NetBeans, have powerful plugins that let you write D scripts and see the data collected by the probes in beautiful graphics.

As a developer, I valued DTrace usefulness more than once. Instead of troubleshooting problems having to dig into the source code and introduce additional code (even in the cases in which aspects come in handy), I could use a D script to observe the application from the outside and quickly collect data that could help me determine where the problem could be.

In some cases, moreover, you could find yourself dealing with situations in which there’s no code available. I could quickly troubleshoot a problem I was having with WebSphere Application Server with a D script instead of relying on WebSphere tracing facilities and the task of interpreting log files.

Conclusion

So much for an introductory post. The possibility of building a development environment as close as possible as your target environment is a “must” for any development platform. Additionally, I consider that working on a environment as close as possible as the production environment not only gives you additional value and insights during an application development stage, but should also considered a mandatory requirement for every project we’re involved into. Solaris provides all of the tools a developer need to accomplish this goal.

Solaris is a complex enterprise operating system with many features you won’t probably ever use. Nevertheless, there’s a use case for many others of them, as I tried to point out in this post. Since some of these technologies were developed with an open source license, they are also available on other operating systems: ZFS is available on FreeBSD and there exist a community effort to port it to OS X; DTrace is available on OS X, Linux and FreeBSD.

The “Solaris advantage” is that all of these technologies are highly integrated and take advantage of each other. The result is worth more than the sum of them. These technologies have got a very polished and easy to use administrative interfaces: when time is important, “How you do it” is fundamental.

I hope that these insights might help you understand if and when the Solaris operating system might be useful to you. Even if you consider that it’s not, I suggest you give it a try anyway: it’s always good to add new technologies to your tool box.

Reference: Some Reasons Why Solaris Is a Great Java Development Platform from our JCG partner at The Grey Blog.

Related Articles :
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button