Skip to main content

Posts

Java Collection Framework

Comes under java.util from java 1.2. before collections vector stack properties classes used to manipulate group of objects. Collections has bring these all to an unified theme and following goals. 1. High performance. Dynamic arrays, linked list, trees, hash table are high efficient. 2. Different collections must work in similar manner with high interoperability. 3. Extending and adapting must me easy. So this is built on few standard interfaces like linked list, hash set, tree set. Own implementations supported too. 4. Allowing integration of standard arrays to collections framework. Algorithms defines static methods to manipulate collections. Iterators allows standard way of accessing collection elements one at a time.(enumeration) Spliterator introduced in Java 8 to provide support for parallel iteration. It has nested interfaces to support primitive types. Jdk 5 added following to collections Genetics Auto boxing/ un boxing For each loop Generics added type safety to t...

Multi White-listing And Advance Throttling with WSO2 API Manager

After spending few sleepless nights found a workaround to do multi IP whitelisting and throttling on API manager as following. Multi IP whitelisting and throttling is not supported by wso2 API manager pack. There are two options we have tried, 1. IP based Throttling Go to API manager admin portal https://13.58.109.76:9444/admin/api-policy-list throttling policies > advanced throttling > add tier Set Request Count as the default limit Set 1 minute as unit time Press on add condition group > press IP condition > press "on" on IP Condition Policy Select specific IP as IP Condition type Add an IP address to be whitelisted and throttled Under Execution Policy Select Request Count as Request Count Set Request Count as you like Set time to 1 minute Press on add condition group again to add the second IP and repeat the same Add this to the API by setting it on "Advanced Throttling Policies" on API manage page on publisher page. Pro...

Slow CPU after resume / Ubuntu 16.04 LTS too slow after suspend and resume

you might experience a slow performance in ubuntu 16.04 after resuming back from a sleep or hibernate. reason for this is it doesn't move away from powersave mode automatically. intel_pstate driver is the one making this problem, so we have to disable it and use acpi-cpufreq  driver. first lets check weather your competer is on powersave.  cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor If your answer is powersave we have to move it to performance state. get your cpu info by cat /proc/cpuinfo | grep MHz  probabaly you seeing 4 cores lets update scaling governers     echo 'performance' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor     echo 'performance' > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor     echo 'performance' > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor     echo 'performance' > /sys/devices/system/cpu/cpu3/cpufreq/scaling_g...

How to Summarize Real Time Event Data Using Siddhi CEP

These days I am working on a task to improve the performance of a wso2telco analytics which is based wso2 DAS. Our product does data summarizing using apache spark. When the data increases it hangs even though we have applied wso2 incremental processing. Hence we decided to do one level data summarizing on real time as soon as data arrives at wso2 siddhi event processor. spark will do summarize per hour while siddhi will summarize per minute. To summarize data in real time we can use siddhi window feature. it can hold the events arrived up to a specified time and then release all the accumulated events at once. Since the events received are released at once we can use summarizing methods to summarize them. Following describes few attempts how I  tried to do this. Attempt 01 This was the attempt suggested by wso2 support team https://github.com/wso2/analytics-apim/blob/master/features/org.wso2.analytics.apim.feature/src/main/resources/template-manager/executionplans/AP...

Java Multithreaded Programming

A program that has two or parts can run concurrently. Each part is a thread. So this is a specialised form multitasking. Process based multitasking is heavyweight and use seperate address spaces. It gives the big picture of the application. JVM has control as it handled by os level. Thread based is light weight and use same address space. So inter communication between threads is easy. This gives detail view of the part it's running. JVM has full control. Multithreading reduces idle time by running another when one is waiting for something like slow network operation. And this avoids application being blocked for something. In a single core CPU no actual parallel threading is happening but CPU time is allocated between threads. Running thread can be suspended and resumed. Can be blocked when waiting. When terminated can't resume. Threads has priorities. Higher priority threads can take cpu power by pushing low or low priority threads can volunteeraly allow if its blocked...