<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pubudhi Witharana on Medium]]></title>
        <description><![CDATA[Stories by Pubudhi Witharana on Medium]]></description>
        <link>https://medium.com/@pubudhiwitharana?source=rss-d36a6f4c36a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NxqnHax0eJZPtrAzD4gZ1w.png</url>
            <title>Stories by Pubudhi Witharana on Medium</title>
            <link>https://medium.com/@pubudhiwitharana?source=rss-d36a6f4c36a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:33:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pubudhiwitharana/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building GemRush: A Journey in Game Development with Python, Pygame and #AmazonQCLI]]></title>
            <link>https://medium.com/@pubudhiwitharana/building-gemrush-a-journey-in-game-development-with-python-pygame-and-amazonqcli-12a253c35367?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/12a253c35367</guid>
            <category><![CDATA[amazon-q-cli]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[2d-game-development]]></category>
            <category><![CDATA[ai-assisted-coding]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 17:28:00 GMT</pubDate>
            <atom:updated>2025-06-03T17:28:00.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*N84YvlHtUegJMOMspk7L-w.png" /><figcaption>GemRush</figcaption></figure><p>Today I want to share the story of how we built GemRush, a charming 2D gem collecting game created entirely with Python and Pygame with <em>AmazonQCLI AI Assistant</em>. This project demonstrates how you can create an engaging game with beautiful visuals and smooth gameplay using accessible programming tools.</p><h4><strong>The Concept</strong></h4><p>GemRush started with a simple premise: create a game where players collect gems against the clock. From this core idea, we expanded to include multiple gem types, a day/night cycle, dynamic lighting, and a competitive leaderboard system. The goal was to create something visually appealing yet technically accessible.</p><h4>Technical Foundation</h4><p>The game was built using:<br>• <strong>Python</strong> as the programming language<br>• <strong>Pygame</strong> for rendering and game mechanics<br>• <strong>PyInstaller</strong> for creating a standalone executable<br>• <strong>AmazonQCLI</strong> AI assistant</p><p>Structured the code into modular components, each handling a specific aspect of the game:</p><pre>gem_collector/<br>├── GemRush.py              # Main game file<br>├── improved_player.py      # Player character with animations<br>├── improved_gems.py        # Detailed gem graphics and animations<br>├── improved_background.py  # Parallax background with day/night cycle<br>├── improved_effects.py     # Particle systems and visual effects<br>├── improved_ui.py          # Enhanced UI elements<br>├── game_timer.py           # Timer system with warnings<br>└── leaderboard.py          # Leaderboard system</pre><h4>Visual Design Evaluation</h4><p>One of the most interesting aspects of developing GemRush was the evolution of its visual design. We started with simple shapes and gradually enhanced them:</p><ol><li>Player Character: From a basic circle to an animated character with idle and movement animations in four directions</li><li>Gems: From geometric shapes to randomly generated gems with unique properties, glowing effects, and sparkles</li><li>Background: From a flat color to a parallax scrolling background with a day/night cycle and twinkling stars</li><li>Effects: Added particle systems for gem collection, player movement trails, and dynamic lighting</li></ol><h4>Gameplay Mechanics</h4><p>The gameplay revolves around collecting gems against the clock:</p><ul><li>Progressive Difficulty: Three levels with increasing challenge (more gems <br>required, less time)</li><li>Gem Variety: Five gem types (diamond, ruby, emerald, sapphire, topaz) with different point values</li><li>Time Management: Collecting gems adds time to the clock, with rarer gems giving bigger bonuses</li><li>Leaderboard System: Tracks scores, completion times, and levels reached</li></ul><h4>Challenges and Solutions</h4><p>Challenge 1: Collision Detection<br>Initially, we had issues with gem collection not working properly. The solution was to implement a more reliable collision detection system that checks for overlaps between the player and gems.</p><p>Challenge 2: Performance Optimization<br>With all the visual effects, we needed to ensure the game ran smoothly. We <br>optimized by:<br>• Using object pooling for particles<br>• Implementing efficient rendering techniques<br>• Limiting the number of simultaneous effects</p><p>Challenge 3: Creating a Standalone Executable<br>To make the game accessible without requiring Python installation, we used PyInstaller to create a standalone executable. This required careful management of dependencies and assets.</p><h4>User Experience Improvements</h4><p>Throughout development, we focused on enhancing the user experience:</p><ol><li>Loading Screen: Added a professional loading screen with progress bar and rotating tips</li><li>Victory Screen: Designed a satisfying victory screen with score display and an exit button</li><li>Desktop Integration: Created a desktop shortcut with a custom icon for easy access</li><li>Leaderboard: Implemented a persistent leaderboard to track achievements</li></ol><h4>Lessons Learned</h4><p>Building GemRush taught us several valuable lessons:</p><ol><li>Modular Design: Breaking the game into separate components made development and debugging much easier</li><li>Iterative Development: Starting simple and gradually adding features allowed us to maintain a working game at all stages</li><li>User Feedback: Continuously testing and adjusting based on feedback helped create a more polished experience</li><li>Performance Matters: Even in a simple 2D game, performance optimization is crucial for smooth gameplay</li></ol><h4>Conclusion</h4><p>GemRush demonstrates that with Python and Pygame, you can create engaging games with rich visuals and smooth gameplay. The modular approach to development allowed us to iteratively improve each aspect of the game while maintaining a cohesive experience.</p><p>The final product includes animated characters, dynamic backgrounds, particle effects, and a complete game loop with multiple levels and a leaderboard system. Best of all, it’s packaged as a standalone executable that anyone can run without installing Python.</p><p>Whether you’re a beginner looking to create your first game or an experienced developer exploring Python for game development, I hope this journey through building GemRush provides inspiration and practical insights for your own projects.</p><p>GitHub: <a href="https://github.com/Pubudhi/GemRush">https://github.com/Pubudhi/GemRush</a></p><p>Happy coding and game development!</p><p>#AmazonQCLI #ai #assistant</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12a253c35367" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservice Architecture Pattern Topologies | in short]]></title>
            <link>https://medium.com/@pubudhiwitharana/microservice-architecture-pattern-topologies-in-short-ae59f46e34a5?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae59f46e34a5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[topology]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Wed, 08 Mar 2023 08:08:55 GMT</pubDate>
            <atom:updated>2023-03-08T08:08:55.926Z</atom:updated>
            <content:encoded><![CDATA[<p>There are several ways to implement microservices architecture, but three main topologies are widely used and popular among practitioners. These include:</p><ol><li><em>API REST-based topology</em></li><li><em>Application REST-based topology</em></li><li><em>Centralized messaging topology</em></li></ol><p><strong>1).API REST-based topology</strong></p><p>The API REST-based topology is suitable for websites that provide small, self-contained services through an API. This topology involves using service components with one or two modules that perform specific business functions independently. These components are accessed through a REST-based interface implemented via a separate web-based API layer. This topology is commonly used by popular cloud-based RESTful web services provided by top software companies in the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*-wG_aWKTNQVUS_LUUL0gsw.jpeg" /><figcaption>Illustration: API REST-based topology</figcaption></figure><p><strong>2).Application REST-based topology</strong></p><p>The application REST-based topology is distinct from the API REST-based approach in that client requests are received through traditional web-based business application screens, rather than through a simple API layer. In this topology, the user-interface layer is deployed as a separate web application that remotely accesses service components through REST-based interfaces. The service components in this topology tend to be larger and more coarse-grained, representing a small portion of the overall business application, rather than single-action services. This topology is commonly used in small to medium-sized business applications with relatively low complexity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*A6m8pZjMoKtwHTooSmNAZw.jpeg" /><figcaption>Illustration: Application REST-based topology</figcaption></figure><p><strong>3).Centralized messaging topology</strong></p><p>The centralized messaging topology is commonly used in larger business applications or those requiring greater control over the transport layer between the user interface and service components. This topology offers advanced queuing mechanisms, asynchronous messaging, monitoring, error handling, and improved load balancing and scalability compared to the simple REST-based topology. The issues of a single point of failure and architectural bottleneck are addressed through broker clustering and broker federation, which split a single broker instance into multiple instances to divide the message throughput load based on functional areas of the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*L8alMdNf5_blMGXRd-u14g.jpeg" /><figcaption>Illustration: Centralized messaging topology</figcaption></figure><p>Happy Learning :) !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae59f46e34a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Types of References in Java in short]]></title>
            <link>https://medium.com/@pubudhiwitharana/types-of-references-in-java-b4d550741b7c?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4d550741b7c</guid>
            <category><![CDATA[core-java]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 15:02:49 GMT</pubDate>
            <atom:updated>2023-02-28T18:02:38.157Z</atom:updated>
            <content:encoded><![CDATA[<p>Here follows summary of four references types in java</p><p><strong>1).Strong Reference : </strong>This is the default type of Reference Object. <em>Any object which has an active strong reference are not eligible for garbage collection</em>. The object is garbage collected only when the variable which was strongly referenced points to null.</p><pre>package garbagecollection;<br><br>class Reference{<br><br>}<br><br>public class StrongReference {<br><br>    public static void main(String[] args) {<br><br>        /**<br>         * Here ‘reference’ object is strong reference to newly created instance of Reference.<br>         * Currently, &#39;reference&#39; is active object so can’t be garbage collected.<br>         **/<br>        Reference reference = new Reference();<br><br>        /**<br>         * &#39;reference&#39; object is no longer referencing to the instance.<br>         * So the &#39;Reference&#39; type object is now available for garbage collection.<br>         **/<br>        reference = null;<br>    }<br>}</pre><p><strong>2).SoftReference : </strong>This is not a default type of Reference Object. The object is garbage collected only when the variable which was strongly referenced points to null.</p><pre>package garbagecollection;<br><br>import java.lang.ref.SoftReference;<br><br>class ReferenceObject{<br><br>    public void method(){<br>        System.out.println(&quot;Hello from ReferenceObject class&quot;);<br>    }<br><br>}<br><br>public class SoftReferenceMain{<br><br>    public static void main(String[] args) {<br><br>        // Strong reference<br>        ReferenceObject softReference = new ReferenceObject();<br>        softReference.method();<br><br>        // Creating Soft Reference to &#39;ReferenceObject&#39; type object to which &#39;softReference&#39; is also pointing.<br>        SoftReference&lt;ReferenceObject&gt; reference = new SoftReference&lt;&gt;(softReference);<br><br>        // &#39;ReferenceObject&#39; type object to which &#39;softReference&#39; was pointing earlier is available for garbage collection.<br>        softReference = null;<br><br>        /**<br>         * The &#39;softReference&#39; object retrieved by get() method of WeakReference class. The &#39;softReference&#39; object which has been weakly referenced.<br>         * It successfully calls the method. ps- At this calling time, &#39;softReference&#39; object not collected by GC.<br>         */<br>        softReference = reference.get();<br><br>        softReference.method();<br>    }<br>}</pre><p><strong>3).WeakReference :</strong> The objects that are referenced only by weak references are garbage collected eagerly; the GC won’t wait until it needs memory in that case.</p><pre>package garbagecollection;<br><br>import java.lang.ref.WeakReference;<br><br>class ReferenceWeakObject{<br><br>    public void method(){<br>        System.out.println(&quot;Hello from ReferenceWeakObject class&quot;);<br>    }<br>}<br><br>public class WeakReferenceDemo {<br>    public static void main(String[] args) {<br><br>        // Strong Reference<br>        ReferenceWeakObject referenceWeakObject = new ReferenceWeakObject();<br>        referenceWeakObject.method();<br><br>        // Creating Weak Reference to &#39;ReferenceWeakObject&#39; type object to which &#39;referenceWeakObject&#39; is also pointing.<br>        WeakReference&lt;ReferenceWeakObject&gt; reference = new WeakReference&lt;&gt;(referenceWeakObject);<br><br>        /**<br>         * Now, &#39;ReferenceWeakObject&#39; type object to which &#39;referenceWeakObject&#39; was pointing earlier is available for garbage collection. <br>         * But, it will be garbage collected only when JVM needs memory.<br>         */<br>        referenceWeakObject = null;<br><br>        // Retrieve back the object which has been weakly referenced. It successfully calls the method.<br>        referenceWeakObject = reference.get();<br><br>        referenceWeakObject.method();<br>    }<br>}</pre><p><strong>4).Phantom Reference : </strong>Garbage collection is allowed for objects that are being referenced via phantom references. But JVM first places them in a queue called the “reference queue” before deleting them from memory. A reference queue is created for them when the finalize() method has been called on them.</p><pre>package garbagecollection;<br><br>import java.lang.ref.PhantomReference;<br>import java.lang.ref.ReferenceQueue;<br><br>class ReferencePhantomObject {<br>    public void method() {<br>        System.out.println(&quot;Hello from SoftReference class&quot;);<br>    }<br>}<br><br>public class PhantomReferencesDemo {<br>    public static void main(String[] args) {<br>        //Strong Reference<br>        ReferencePhantomObject referencePhantomObject = new ReferencePhantomObject();<br>        referencePhantomObject.method();<br><br>        //Creating reference queue<br>        ReferenceQueue&lt;ReferencePhantomObject&gt; referenceQueue = new ReferenceQueue&lt;&gt;();<br><br>        //Creating Phantom Reference to &#39;ReferencePhantomObject&#39; type object to which &#39;referencePhantomObject&#39; is also pointing.<br>        PhantomReference&lt;ReferencePhantomObject&gt; phantomReference = new PhantomReference&lt;&gt;(referencePhantomObject, referenceQueue);<br><br>        /**<br>         * Now, &#39;ReferencePhantomObject&#39; type object to which &#39;referencePhantomObject&#39; was pointing earlier is available for garbage collection.<br>         * But, this object is kept in &#39;referenceQueue&#39; before removing it from the memory.<br>         */<br>        referencePhantomObject = null;<br><br>        //It always returns null.<br>        referencePhantomObject = phantomReference.get();<br><br>        //It shows NullPointerException.<br>        referencePhantomObject.method();<br>    }<br>}</pre><p>Happy learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4d550741b7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Microservices Architecture: Key Concepts and Benefits]]></title>
            <link>https://medium.com/@pubudhiwitharana/understanding-microservices-architecture-key-concepts-and-benefits-a937cae64296?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a937cae64296</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 18:10:43 GMT</pubDate>
            <atom:updated>2023-02-27T18:10:43.826Z</atom:updated>
            <content:encoded><![CDATA[<p>The microservices architecture pattern is an increasingly popular way of designing software applications. <strong>It is seen as a viable alternative to monolithic applications and service-oriented architectures</strong>. However, because this architecture pattern is still evolving, there is a lot of confusion in the industry about what this pattern is all about and how it is implemented.</p><p>To understand the microservices architecture pattern, there are several core concepts that are important to grasp. The first of these concepts is the <strong>notion of separately deployed units</strong>. Each component of the microservices architecture is deployed as a separate unit, allowing for easier deployment through an effective and streamlined delivery pipeline, increased scalability, and a high degree of application and component decoupling within your application.</p><p>Perhaps the most important concept to understand with this pattern is the <strong>notion of a service component</strong>. Rather than thinking about services within a microservices architecture, it is better to think about service components. Service components can vary in granularity from a single module to a large portion of the application. Service components contain one or more modules that represent either a single-purpose function or an independent portion of a large business application. Designing the right level of service component granularity is one of the biggest challenges within a microservices architecture.</p><blockquote>Another key concept within the microservices architecture pattern is that it is a <strong>distributed architecture</strong>. This means that all the components within the architecture are fully decoupled from one another and accessed through some sort of remote access protocol (JMS, AMQP, REST, SOAP, RMI, etc.).</blockquote><blockquote><strong>The distributed nature of this architecture pattern is how it achieves some of its superior scalability and deployment characteristics.</strong></blockquote><p>The microservices architecture evolved from issues associated with other common architecture patterns, rather than being created as a solution waiting for a problem to occur. The microservices architecture style naturally evolved from two main sources: monolithic applications developed using the layered architecture pattern and distributed applications developed through the service-oriented architecture pattern.</p><p>The rise of the common cycles typically found in most large IT firms prompted the development of continuous delivery, the notion of a continuous deployment pipeline from development to production which streamlines the deployment of applications.</p><p>Monolithic applications typically consist of tightly coupled components that are part of a single deployable unit, making it cumbersome and difficult to change, test, and deploy the application. These factors commonly lead to brittle applications that break every time something new is deployed. The microservices architecture pattern addresses these issues by separating the application into multiple deployable units (service components) that can be individually developed, tested, and deployed independent of other service components.</p><p>The other evolutionary path that led to the microservices architecture pattern is from issues found with applications implementing the service-oriented architecture pattern (SOA). While the SOA pattern is powerful and offers unparalleled levels of abstraction, heterogeneous connectivity, service orchestration, and the promise of aligning business goals with IT capabilities, it is complex, expensive, ubiquitous, difficult to understand and implement, and is usually overkill for most applications. The microservices architecture style addresses this complexity by simplifying the notion of a service, eliminating orchestration needs, and simplifying connectivity and access to service components.</p><p>In summary, the microservices architecture pattern is a powerful way of designing software applications. It separates the application into multiple deployable units (service components) that can be individually developed, tested, and deployed independent of other service components. It simplifies the notion of a service and connectivity and access to service components. However, designing the right level of service component granularity is one of the biggest challenges within a microservices architecture.</p><p>Happy learning ☺</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a937cae64296" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka Topics and Partitions]]></title>
            <link>https://medium.com/@pubudhiwitharana/kafka-topics-and-partitions-f18f1cef9daf?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f18f1cef9daf</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[kafka-topic]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Tue, 07 Apr 2020 17:32:34 GMT</pubDate>
            <atom:updated>2020-04-07T17:32:34.613Z</atom:updated>
            <content:encoded><![CDATA[<p>Kafka Topic is format of multiple partitions. So let’s what this means. Topic is basically a stream of data, the same way you have tables on the databases. You have topics in Kafka you can just publish data to it. You can have as many topics as you want. The only thing is that they have to have different names, because the topic is identified by its name. Then topics are split. They’re split in what is called partition. So a partition is basically a part of the topic and the data within the partition is ordered. We will see that means and each message within the partition, that’s your actual data will get an incremental id. So a number and that number starts at zero and goes all the way to whatever and that number is called an offsets. I have put together a little graph follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*3yAI27xw2koAuffmExymww.png" /><figcaption>Kafka topic partitioning</figcaption></figure><p>Let’s take a topic and there’s partition 0 which is the first partition . You will write a message to it and have the upset to ‘0’, then you’ll write an other message to it and you’ll have upset ‘1’ then ‘2’, ‘3’ so on. So The offsets increment from 0 in this case 11 as you write data. Then, the topic is multiple of partitions so we’ll have partition 0, partition 1 and partition 2. Each partitions are their own offsets. So for partition 1, the offsets go from 0 to 7 and for partition 2 the offsets go from 0 to 8 and next offset would be 9 as you can see the writes are done from zero and then increment. So this whole set of partitions 0 -2, that’s what makes your topics. It’s a really important concept here.</p><p>Now offsets that only have a meaning for a specific partition, so for example upset number three in the partition does not represent the same data as offset number three in partition on so as you see before if we take upsets number seven in partition zero, it does not mean anything except for partition one , partition two. You may have other data completely different. you have no idea so offsets are only for specific partition the order is guaranteed only within the partition. So if you write data in partition zero, it will be in order and if actually want to be in order but you cannot guarantee the order between partition zero and partition one, the offsets are independent then within the partition and it’s specific to a specific attribute of Kafka the data will be kept only for limited time the default, I think its two weeks. So after two weeks, this two weeks of data will just disappear. So upset zero will go away. But the offsets will still increase but offset zero will never been re-visited again. So which brings up to the four concept once the data is written to a partition it cannot be changed. That’s the concept called ‘immutability’. That’s really important once you make a right gap you. You cannot overwrite it you can write an update but this will be next upsets and that’s it. Then you push data you don’t push it out to a partition you push data to topic and to note to which partition it’s going to go to. It’s randomly assigned at first unless you provide a key.</p><p>Finally you can have as many partitions as you want for a topic. <strong><em>The more partitions — the more parallelism</em></strong>. So that’s it for topic and partitioning. Remember the offset that only have meaning for a specific topic partition.</p><p>Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f18f1cef9daf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Apache Kafka? ‍♀️‍♂️]]></title>
            <link>https://medium.com/@pubudhiwitharana/what-is-apache-kafka-%EF%B8%8F-%EF%B8%8F-2741f6667856?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/2741f6667856</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 20:55:28 GMT</pubDate>
            <atom:updated>2020-03-04T20:55:28.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*q_mOrXK91eqFP02borqrSw.png" /><figcaption>Apache Kafka</figcaption></figure><p>What is Apache Kafka is; Let’s first check the background of it. For a long time now, we have written programs that store information in databases. Now what databases encourage us to do is to think of the world in terms of <strong>things: </strong>like what we can see out of the world. for example living (users, employees) and physical(car, train), these things have some <strong>state.</strong> We take that state and store it in the databases. This worked for a decade. But people are finding that better, rather than <em>thinking of things first, or thinking of events first. </em>Because events have some states too. Also, the event has a description of what happens with it. But the primary idea is that the event is an indication in the time that thing took place. But now a little bit cumbersome to store events in databases. Instead, we use a structure called a log: is an ordered sequence of these events.</p><p>An event happens and we write it into a log. A little bit of state, a little bit of description of what happens and that says, “ <em>Hey, that event happened at that time</em>”. Logs are really easy to think about and also they’re easy to build at a scale that historically has not quite been true of databases. Which have been a little cumbersome in one way or another to build at scale.</p><p>Now Apache Kafka is a system for managing these logs using fairly standard, historical a term. It calls them “<strong>Topics”</strong>. A topic is an ordered collection of events that are stored in a durable way. Durable means that they’re written in a disk and they’re replicated. So they’re stored on more than one disk, on more than one the server, somewhere whatever infrastructure runs. So that there’s no hardware failure that can make that data go away. Topics can store data for a short period of time, little few hours and days or years or indefinitely. Topics also can be relatively small or they can be enormous. There is nothing about the economics of Kafka, that says that topics have to be large in order for it to make sense, and there’s nothing about the architecture of Kafka. That says that they have to say small. So they can be small, they can be big. They can remember the data forever. They can remember data just for a little while but they’re persistent records of events. Each one of those events represents a thing happening in the business. Like users, maybe updates his or her shipping address or train unload the cargo, etc. Each one of the things can be an event stored in a topic and Kafka encourages you to think of <strong><em>“events first” </em></strong><em>and </em><strong><em>“things second”</em></strong>.</p><p>Now back when databases ruled the world, it was kind of the trend to build one large program, that uses one big database all by itself and it was customary, for a number of reasons to do. But these things grew to a point where they were difficult to change and also difficult to think about. They got too big for any developer to fit that whole program in his or her head at the same time. And if you’re lived like this you know that that’s true.</p><p>Now the trend is to write lots and lots of small programs each one of which is small enough to fit in your head and think about and version and change and evolve all on its own. And these things can talk to each other through Kafka topics. So each one of these services can consume messages from a Kafka topic, do whatever its computation is that goes to on there and the produced that message off to another topic. That output now durably and maybe even permanently recorded for other services and data in these persistent real-time streams.</p><p>Now it&#39;s possible to build new services that perform real-time analytics of that data. Some sort of real-time analytics dashboard and that is consuming messages from this topic. That’s in contrast to the way it used to be where we can run a batch process overnight. Also, it’s possible that yesterday a long time ago for some business now. You might want that insight or as those to instant as it can possibly and with data in these topics as events, that get processed as soon as they happen. it’s now fairly straightforward to build these services that can do that analysis in real-time. So you’ve got events, you’ve got topics, you’ve got all services that talking to each other through topics and you’ve got real-time analytics. I think if you’ve got those four of things in your head you’ve got a decent idea of kind of the minimum viable understanding not only of what Kafka is, Which is this distributing log thing but also of the kind of software architecture that Kafka tends to give rise to when people start building system on it this what happens.</p><p>Happy learning 😊✌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2741f6667856" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wiremock — 1 — Getting Start]]></title>
            <link>https://medium.com/@pubudhiwitharana/https-medium-com-pubudhiwitharana-wiremock-1-getting-start-ea4bbf58f987?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea4bbf58f987</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[mocking]]></category>
            <category><![CDATA[stubbing]]></category>
            <category><![CDATA[wiremock]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 18:23:40 GMT</pubDate>
            <atom:updated>2019-09-17T18:23:40.172Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wiremock — 1 — Getting Started</h3><p><strong>WireMock</strong> is a library for stubbing and mocking web services was a open source project originally created by Tom Akehurst in 2011. It constructs a HTTP server that we could connect to as we would to an actual web service.When a <a href="http://wiremock.org/">WireMock</a> server is in action, we can set up expectations, call the service, and then verify its behaviors.</p><p>At its core it is web server that can be primed to serve canned responses to particular requests (stubbing) and that captures incoming requests so that they can be checked later (verification).It also has an assortment of other useful features including record/playback of interactions with other APIs, injection of faults and delays,<strong> simulation of stateful behavior</strong>.All of features are accessible via its REST (JSON) interface and its Java API. Additionally, stubs can be configured via JSON files.</p><p>WireMock is distributed in two flavours — a standard JAR containing just WireMock, and a standalone fat JAR containing WireMock plus all its dependencies.</p><h4><strong>Environment setup and prerequisite</strong></h4><ol><li>Wiremock standalone jar <a href="http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.24.1/wiremock-standalone-2.24.1.jar">http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.24.1/wiremock-standalone-2.24.1.jar</a></li><li>Java 8</li><li>Postman (Testing Version 6.1.3)</li><li>Atom ( Version <a href="https://github.com/atom/atom/releases/tag/v1.40.1">1.40.1</a>) or preferred text editor</li><li>Windows 10 OS</li></ol><p>Getting start with wiremock at the very first time: first you need create suitable location/folder and copy the wiremock standalone jar into it.open the cmd from the current location(jar containing location) and follow the following command.</p><pre>java -jar wiremock-standalone-2.24.1.jar --port=9999 --verbose</pre><p>--port: Set the HTTP port number</p><p>--verbose: Turn on verbose logging to stdout</p><p>--help: Show command line help</p><p>If you get following console output: first step done, if not repeat above steps once more time ;).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*Fqtl5zAKMGOFzAuteJgiWQ.png" /><figcaption>wiremock-server</figcaption></figure><p>Then, you need to shutdown the server and check the your current file location. There will be two new directories which are created by the wiremock server ‘mapping’ and ‘__files’. Under the mapping directory we can save our all json files which are having requests and responses. __files director uses to read the body content from a file. Create json(ex. helloworld.json) file which contains follow json in the mapping directory.</p><pre>{<br>    &quot;request&quot;: {<br>        &quot;method&quot;: &quot;GET&quot;,<br>        &quot;url&quot;: &quot;/hello/wiremock&quot;<br>    },<br>    &quot;response&quot;: {<br>        &quot;status&quot;: 200,<br>        &quot;body&quot;: &quot;Hello Wiremock!&quot;,<br>        &quot;headers&quot;: {<br>            &quot;Content-Type&quot;: &quot;text/plain&quot;<br>        }<br>    }<br>}</pre><p>Now use postman and try to get a response from GET method and following url.</p><p><a href="http://localhost:9999/hello/wiremock">http://localhost:9999/hello/wiremock</a></p><pre>Hello Wiremock!</pre><p>If you get above response body from the postman. Up to this level you done.</p><p>Let’s discuss advanced concepts in future ! Happy Coding ✌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea4bbf58f987" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Scala ?]]></title>
            <link>https://medium.com/@pubudhiwitharana/what-is-scala-9f6696d90a9a?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f6696d90a9a</guid>
            <category><![CDATA[intellij]]></category>
            <category><![CDATA[scala-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[sublime-text-3]]></category>
            <category><![CDATA[atom]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 17:46:05 GMT</pubDate>
            <atom:updated>2018-09-30T17:46:05.586Z</atom:updated>
            <content:encoded><![CDATA[<p>The modern multi-paradigm programming language 🤗</p><p>Here follow content based on the what is Scala, about the Scala, what are the prerequisites and finally installation in windows.</p><p><strong>01. What is Scala?</strong></p><p>Scala is computer programming language which has been created by <strong>Martin Odersky</strong> and released first version in 2003. Scala; The Scalable Language is a general purpose language which helps to developers who wants to write programs in concise, elegant and type-safe way. Scala is similar to scripting language also one most user friendly language.This multi-paradigm language integrates with object-oriented and functional languages.</p><p><strong>02. About the Scala</strong></p><p>The most important thing is, scala runs on the Java Virtual Machine(JVM).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*xUM_Mzg0WY2i1Yb1OmWMJw.png" /><figcaption>Fig 01 : Scala and Java behavior in JVM</figcaption></figure><p>(1) : This is the place you write the code.***Also this works with existing Java code stack.</p><p>(2) : Scala compilation is similar to java code compilation. It uses scalac for the compilation. In this case most of times you can use IDE( Integrated Development Environment)</p><p>(3) : In this phase compiled classes are converted into <strong>bite codes</strong> which can understand by the JVM and also JVM can monitor your code will eventually run from.</p><p><strong>03. Prerequisites for learning Scala</strong></p><p>Scala is based Java as you seen above content, if you are aware of Java syntax and OOP concepts ,then you are ready to learn Scala or else if you know basics in C, C++ or Python it also seems you ready to step in!</p><p><strong>04. Scala installation in windows</strong></p><ul><li><strong>1. </strong>You need to verify <a href="https://www.oracle.com/technetwork/java/javase/downloads/index.html"><strong>JDK</strong></a> installation in your machine.</li><li><strong>2. </strong>Download Scala <a href="https://downloads.lightbend.com/scala/2.12.7/scala-2.12.7.msi"><strong>Download the Scala binaries for windows</strong></a>(based on your preferences you can download latest version instead of downloading Long Term Support version) version and run the file.</li></ul><p>here follow the steps of installation,</p><p><strong>Step 01</strong> : Run the .msi file downloaded in 4.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*jyb2LFwmr_yUtoa4J9hiOw.png" /><figcaption>Fig 02 : Step 01</figcaption></figure><p><strong>Step 02</strong> : Click ‘<strong>Next</strong>’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*u1SBbPKsWnMvKHurkzyZJg.png" /><figcaption>Fig 03 : Step 02</figcaption></figure><p><strong>Step 03 : </strong>Read the End-User License Agreement 😁 and put a tick bottom line and finally click on ‘<strong>Next</strong>’ button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*wM6mbNrM5AeSxQbsqQVeqw.png" /><figcaption>Fig 04 : Step 03</figcaption></figure><p><strong>Step 04 </strong>: In this step you can change the installation path or keep it as it is (most of times it’s better to keep default if you are a beginner😉 )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*oWngJl_HHev2UDp5z6xJYw.png" /><figcaption>Fig 05 : Step 04</figcaption></figure><p><strong>Step 05</strong> : Click the ‘<strong>Install</strong>’ wait until the installation completion.</p><p><strong>Step 06</strong> : Finally click ‘<strong>Finish</strong>’ command and now you successfully completed the installation 🤩🤩🤩</p><p><strong>Step 07</strong> : Open command prompt and type command ‘scala’, and if you successful you can see following cmd, Yes You DONE!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TkzteyH7zxdeNMJTX-4y_A.png" /><figcaption>Fig 06 : Step 05</figcaption></figure><p>***If you can not reach this step go back and check all steps carefully and try it again!!! (never give up, because errors make lots of fun 😂)</p><p><strong>05. Choosing a development environment</strong></p><p>Basically development environment is based on your preferences. I personally not recommend IDE for the very first time, better to get experiences with terminal or notepad/editor.</p><ul><li>Terminal / Shell based</li><li>Notepad / Editor based (<a href="https://www.sublimetext.com/3">Sublime Text 3</a>, <a href="https://atom.io/">Atom</a>)</li><li>IDE (<a href="https://www.jetbrains.com/idea/">IntelliJ Idea</a> (user friendly and easy to built application using sbt))</li></ul><p><strong>Happy Coding :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f6696d90a9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Spark RDD ?]]></title>
            <link>https://medium.com/@pubudhiwitharana/what-is-spark-rdd-5f822fa04ce6?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f822fa04ce6</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Sat, 22 Sep 2018 10:36:41 GMT</pubDate>
            <atom:updated>2018-09-26T12:16:43.161Z</atom:updated>
            <content:encoded><![CDATA[<p>The core of the Spark is the idea of a Resilient Distributed Dataset(RDD). RDDs are mutable, lazily evaluated and cache-able. RDD is read only, partitioned collection of records. RDD faster and does efficient MapReduce operations. In addition of the RDD traits, RDD records have types and Process data in parallel.</p><p>Resilient Distributed Dataset has four main features:</p><ul><li>Distributed collection of data</li><li>Fault-tolerant</li><li>Parallel operation- partitioned</li><li>Ability to use many data sources</li></ul><p>Spark RDD looks alike in general sense:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*wgrFUyJwxq9gR1FMEPqRig.png" /><figcaption>Fig 01: Spark RDD</figcaption></figure><p>SparkContext/ SparkSession is the Driver program. Cluster manager manages different worker nodes and executing the tasks. There are two types of RDD operations:</p><ul><li><strong>Transformations</strong></li><li><strong>Actions</strong></li></ul><p>Transformations basically a recipe to follow and Actions perform what the recipe says to do and returns something back. There are lots of transformations and actions here are some:</p><p>Transformations : map(), filter(), flatMap(), groupByKey(), reduceByKey(), partitionBy(), union(), join(), mapValues(), etc.</p><p>Actions: count(), collect(), reduce(), lookup(), save()</p><p>further reference : <a href="http://spark.apache.org/docs/latest/rdd-programming-guide.html#rdd-operations">http://spark.apache.org/docs/latest/rdd-programming-guide.html#rdd-operations</a></p><p><strong>Happy Coding :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f822fa04ce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Apache Spark]]></title>
            <link>https://medium.com/@pubudhiwitharana/introduction-to-apache-spark-d4869b1f8c0f?source=rss-d36a6f4c36a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4869b1f8c0f</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[scala-programming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Pubudhi Witharana]]></dc:creator>
            <pubDate>Sun, 16 Sep 2018 13:24:54 GMT</pubDate>
            <atom:updated>2018-09-16T14:10:43.700Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://spark.apache.org/">Apache spark</a> is the lightning-fast unified analytic engine with the massive benefits 😮!!! Let’s focus about the spark.</p><p>Why do we need spark?🤔</p><p>The industry needs powerful engine that filled with powerful functionalities with process streaming data as well as batch processing and also requires engine that can response sub-second and perform in-memory processing. here follow some drawbacks from technologies used:</p><p>👀 Hadoop MapReduce can only perform for the batch processing.<br> 👀 Apache Storm and S4 can only perform stream processing. <br> 👀 Apache Imapala and Tez can only perform interactive processing.<br> 👀Apache Giraph and Neo4j can only perform graph processing</p><p>Based on requirements of the industry growth need a powerful engine with multiple processing performances.</p><p>Apache spark is Open Source engine which provides real-time stream processing, interactive processing, graph processing, in-memory processing , batch processing with the very fast speed , ease of use and standard interface.</p><p>🔶<strong>Languages support to spark:</strong></p><p>⚫<em>Scala — </em>Apache Spark framework is built in Scala Language, therefore latest and greatest features can experienced that might not be available in other supported programming languages.</p><p><em>⚫Python — </em>Python programming language has best libraries for data analysis and machine learning like Pandas and Sci-kit learn but they are comparatively slower than Scala.</p><p><em>⚫R — </em>R programming language is best for machine learning and statistical analysis which helps increase developer productivity. SparkR is combination of R along with Spark. SparkR uses data processing that cannot handled by a single machine.</p><p><em>⚫Java — </em>Java programming language good choice for developers who are coming from java and hadoop platform but java does not support RPEL.</p><p><strong>Apache Spark Ecosystem</strong></p><p>🔶<strong>Spark Components</strong></p><p><em>⚫Apache Spark Core — </em>This the foundation for parallel and distributed processing of large data sets. Spark core responsible for all basic I/O functionalities, scheduling and monitoring the jobs on the spark clusters, tasks dispatching, networking with different storage systems, fault recovery and efficient memory management.</p><p><em>⚫Spark SQL — </em>Leverage the power of declarative queries and optimized storage by running SQL like queries on Spark data that is present in RDDs and the other external sources.</p><p><em>⚫Spark Streaming — Allows developers to perform batch processing and streaming of data with ease in the same application.</em></p><p><em>⚫Spark MLlib —</em> MLlib eases the development and for the scalable machine learning pipelines.</p><p><em>⚫Spark GraphX — </em>can work with graph and non-graph sources to achieve flexibility and resilience in graph construction and transformation.</p><p><em>⚫ SparkR — </em>this is the tool for running R on Spark and very similar to python API except that it follows R’s syntax instead of Python.</p><p>🔶Techyon(An in-memory file system) — in-memory computation has gained traction recently as can perform interactive and fast queries because of it. Major drawback of this Techyon is depends on the JVM. When JVM crashes in-memory data will be lost and it takes time to load the data again to the memory.</p><p>🔶Cluster Management</p><p><em>⚫Standalone Cluster —</em> In this mode each application runs and executor an every node within the cluster.</p><p><em>⚫Apache Mesos —</em> In this mode fine grained sharing option so Spark shell scales down its CPU allocation during the execution of multiple commands especially when several users are running interactive shells.</p><p><em>⚫YARN — </em>This mode comes along with hadoop distribution and only cluster manager in spark that supports security. YARN allows dynamic sharing and central configuration of the same pool of cluster resources between various framework that run on YARN<em>.</em></p><p>Apache Spark gaining best industry-standard engine for big data processing since 2016 because of its interactive performance, fault tolerance and the productivity benefits.</p><p><strong>Happy Coding :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4869b1f8c0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>