Posts

Showing posts with the label wso2

Ballerina Services in Serverless World

Ballerina is a new programming language being developed by WSO2 . Ballerina is optimized for integration and it makes writing HTTP services very easy. I wrote a Medium story about Ballerina Services in Serverless World , which discusses how you can deploy your own Ballerina Service as a serverless function in AWS Lambda .

Benchmarking Java Locks with Counters

Image
These days I am analyzing some Java Flight Recordings from taken from WSO2 API Manager performance tests and I found out that main processing threads were in "BLOCKED" state in some situations. The threads were mainly blocked due to "synchronized" methods in Java. Synchronizing the methods in a critical section of request processing causes bottlenecks and it has an impact on the throughput and overall latency. Then I was thinking whether we could avoid synchronizing the whole method. The main problem with synchronized is that only one thread can run that critical section. When it comes to consumer/producer scenarios, we may need to give read access to data in some threads and write access to a thread to edit data exclusively. Java provides ReadWriteLock for these kinds of scenarios. Java 8 provides another kind of lock named StampedLock . The StampedLock provides an alternative way to the standard  ReadWriteLock  and it also supports optimistic...

Specifying a custom Event Settings file for Java Flight Recorder

Image
When you are using Java Flight Recorder (JFR), the JFR will use an event settings file to check which event types to record. By default in JFR, there are two settings, "default" and "profile". The default setting is recommended for Continuous Recordings as it has very low overhead (typically less than 1% overhead). The profile setting has more events and useful when profiling the application. As mentioned in my previous blog post regarding  Java Flight Recorder Continuous Recordings , we use following arguments to do a Continuous Recording. -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,repository=./tmp,dumponexit=true,dumponexitpath=./ Note: According to the Oracle documentation on " java " command, we should be able to specify "settings" parameter to the -XX:FlightRecorderOptions. However, the settings parameter has no effect when used with the -XX:FlightRecorderOptions and ...

Running Java in a Script

Recently I wanted to invoke a JMX operation in a WSO2 server from a script. I was first thinking of writing a simple Java class with a main method and run it as an executable jar file. Then I found that we can run a script with the command " jrunscript ". I also found an example of interacting with a JMX MBean from Javascript . However this example didn't work with Java 8. The reason is that from Java 8, the JavaScript Engine for the JVM is Oracle Nashorn . In Java 7, the JavaScript Engine is based on Mozilla Rhino. Let's see the difference: Following script works with Java 7, but not with Java 8 packages = new JavaImporter(java.lang, java.lang.reflect); with (packages) { // create Java String array of 5 elements var a = Array.newInstance(String, 5); // Accessing elements and length access is by usual Java syntax a[0] = "scripting is great!"; print(a.length); print('\n'); print(a[0]); print('\n'); } ...

Monitor WSO2 Carbon logs with Logstash

Image
The ELK stack  is a popular stack for searching and analyzing data. Many people use it for analyzing logs. WSO2 also has a full-fledged Big Data Analytics Platform, which can analyze logs and do many more things. In this blog post, I'm explaining on how to monitor logs with  Elasticsearch , Logstash and Kibana . I will mainly explain logstash configurations. I will not show how to set up Elasticsearch and Kibana. Those are very easy to setup and there are not much configurations. You can just figure it out very easily! :) If you want to test an elasticsearch server, you can just extract the elasticsearch distribution and start an elasticsearch server. If you are using Kibana 3, you need to use a web server to host the Kibana application. With Kibana 4, you can use the standalone server provided in the distribution. Configuring Logstash Logstash  is a great tool for managing events and logs. See  Getting Started with Logstash  if you haven't used ...

Java Mission Control & Java Flight Recorder

Image
Last year, I got two opportunities to talk about Java Mission Control & Java Flight Recorder. I first talked about " Using Java Mission Control & Java Flight Recorder " as an internal tech talk at WSO2 . I must thank Srinath for giving me that opportunity. After that, Prabath also invited me to do a talk at Java Colombo Meetup . Prabath, Thank you for inviting me and giving me the opportunity to talk at the Java Colombo Meetup! I'm also very excited to see that Marcus Hirt , the Team Lead for Java Mission Control has mentioned about the Java Colombo Meetup in his blog post: " My Favourite JMC Quotes ". It's so nice to see "Sri Lanka" was mentioned in his blog post! :) From Marcus' Blog Here are the slides used at the meetup. Java Colombo Meetup: Java Mission Control & Java Flight Recorder from Isuru Perera Marcus Hirt's blog posts really helped me to understand JMC & JFR concepts and his t...

Enabling Java Security Manager for WSO2 products

Why Java Security Manager is needed? In Java, the Security Manager is available for applications to have various security policies. The Security Manager helps to prevent untrusted code from doing malicious actions on the system.  You need to enable Security Manager, if you plan to host any untrusted user applications in WSO2 products, especially in products like WSO2 Application Server . The security policies should explicitly allow actions performed by the code base. If any of the actions are not allowed by the security policy, there will be a SecurityException .  For more information on this, you can refer Java SE 7 Security Documentation . Security Policy Guidelines for WSO2 Products When enabling Security Manager for WSO2 products, it is recommended to give all permissions to all jars inside WSO2 product. For that, we plan to sign all jars using a common key and grant all permissions to the signed code by using "signedBy" grant as follows. grant sign...

Java Performance Monitoring Libraries

There is a proposal to  build performance probes in WSO2 Platform . For that I started looking in to some performance monitoring libraries. Following libraries were mentioned in the WSO2 architecture thread. Metrics Parfait JAMon (Java Application Monitor) While looking in to these libraries, I found out about following also. Java Simon - Simple Monitoring API Perf4J Here is a quick comparison of each project. These comparison criteria are based on the requirements in above proposal. Metrics Parfait JAMon Java Simon Perf4J License Apache License 2.0 Apache License 2.0 JAMon License New BSD License Apache License 2.0 Source GitHub Google Code Sourceforge GitHub GitHub Latest Version 3.1.0 0.2.8 2.79 4.0.0 0.9.16 Last Published Sep 4, 2014 Jun 01, 2011 Aug 20, 2014 Oct 29, 2014 Oct 16, 2011 Java Version - Java 6 - Java 7 - Counts Yes Yes Yes Yes No Timings Yes Yes Yes Yes Yes JMX Support Yes Yes No Yes Yes Enable/Disable No No* Yes Yes Yes* * Not ...

Monitoring WSO2 products with logstash JMX input plugin

These days, I got the chance to play with ELK  ( Elasticsearch , Logstash & Kibana ). These tools are a great way to analyze & visualize all logs. You can easily analyze all wso2carbon.log files from ELK. However we also needed to use ELK for monitoring WSO2 products and this post explains the essential steps to use logstash JMX input plugin to monitor WSO2 servers. Installing Logstash JMX input plugin Logstash has many inputs and the JMX input plugin is available under "contrib" We can use "plugin install contrib" command to install extra plugins. cd /opt/logstash/bin sudo ./plugin install contrib Note: If you use logstash 1.4.0 and encounter issues in loading the jmx4r, please refer Troubleshooting below. Logstash JMX input configuration When using the JMX input plugin, we can use a similar configuration as follows. We are keeping the logstash configs in "/etc/logstash/conf.d/logstash.conf" input { jmx{ path ...

Why you should attend WSO2Con Asia 2014

WSO2Con Asia 2014 , a must attend conference for anyone interested in WSO2 products, is just around the corner. The WSO2Con Asia 2014 is scheduled from March 24 to March 26 with two conference days and one pre-conference tutorial day. Have a look at WSO2Con Asia 2014 Agenda for all interesting talks and tutorials WSO2 has to offer. The conference will be held at Waters Edge , a popular venue in Sri Jayawardenapura Kotte, Sri Lanka. Here are few reasons I can think of as to why you should attend the WSO2Con. WSO2 is the only company to have a complete set of open source middleware products built from scratch and WSO2Con is a good opportunity for you to learn how we make world-class products. Pre-conference tutorials will help you to get an understanding of how our stuff works. So, don't worry if you do not have much idea about the WSO2 products. See what WSO2 has to offer with WSO2 Mobile subsidiary. Meet the experts. Networking opportunities. Discover how WSO2 sof...

What is WSO2 Private PaaS?

Image
In this blog post, I'm going to briefly introduce the WSO2 Private PaaS , an upcoming product from WSO2. Even though I'm writing about this now, the WSO2 Private PaaS term coined just few weeks after we donated WSO2 Stratos to Apache Foundation in June 2013. Apache Stratos (incubating) and WSO2 Private PaaS The WSO2 Private PaaS is built on top of the Apache Stratos (incubating) project, which is currently undergoing major architectural changes from the initial 3.0.0-incubating version. Following are few major changes you can expect in the next Apache Stratos (incubating) release. i.e. 4.0.0-incubating version. Using a message broker for communication among core Stratos components. Auto scaling now analyze real time data from cartridges like in flight request count and load average. Currently this data is analyzed using  WSO2 Complex Event Processor Load Balancer is now a cartridge in Stratos New Stratos Manager UI Stratos Manager now has RESTful servic...

WSO2 Stratos 2.0 Foundation is Released!

We are happy to announce that WSO2 Stratos 2.0 Foundation General Availability (GA) is released!!! Nothing much changed from the RC2 release. Please refer my previous post for more details about Stratos 2.0 and here is link to release note mail! We updated our Amazon EC2 images with Stratos 2.0 GA release and you can find more details in our  Quick Start Guide  wiki page. Visit our Stratos wiki page for more information:  http://docs.wso2.org/wiki/display/Stratos200/WSO2+Stratos+Documentation

WSO2 Stratos 2.0 Foundation - RC2 Released!

Today we released WSO2 Stratos 2.0 Foundation Release Candidate 2, which will be the final release candidate of the upcoming Stratos 2.0 GA. WSO2 Stratos 2.0 is the next major version of WSO2 Stratos 1.x, the most complete, enterprise-grade, open PaaS, with support for more core services than any other available PaaS today. This release also comes with a very easy to configure demo setup that can be run on Amazon EC2 and you can find more details in our  Quick Start Guide  wiki page. Following are the Key features available in Stratos 2.0. Key Features Artifact Distribution Coordinator (ADC) with support for external Git and GitHub repositories. Plug-able architecture support for adding new cartridges Support for PHP, Tomcat and MySQL and WSO2 Carbon cartridges (AS, ESB, BPS etc.) Support for puppet based cartridge creation for WSO2 Carbon cartridges Elastic Load Balancer (ELB) with Cartridge support Multiple IaaS support (EC2,...