<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ramesh0807</title>
    <description>The latest articles on DEV Community by Ramesh0807 (@ramesh0807).</description>
    <link>https://dev.to/ramesh0807</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F463990%2Fcc1031eb-2db4-4a80-b330-37fac9a78c43.png</url>
      <title>DEV Community: Ramesh0807</title>
      <link>https://dev.to/ramesh0807</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramesh0807"/>
    <language>en</language>
    <item>
      <title>Let's explore OOP concepts using the example of a Royal Enfield motorcycle</title>
      <dc:creator>Ramesh0807</dc:creator>
      <pubDate>Fri, 11 Aug 2023 15:45:35 +0000</pubDate>
      <link>https://dev.to/ramesh0807/lets-explore-oop-concepts-using-the-example-of-a-royal-enfield-motorcycle-414</link>
      <guid>https://dev.to/ramesh0807/lets-explore-oop-concepts-using-the-example-of-a-royal-enfield-motorcycle-414</guid>
      <description>&lt;p&gt;Object-Oriented Programming (OOP) is a programming paradigm that revolves around the concept of organizing data and code into objects, which are instances of classes. OOP encourages the use of classes and objects to model real-world entities and their interactions&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;: A class is a blueprint for creating objects. In the context of a Royal Enfield bike, we can define a &lt;strong&gt;Bike&lt;/strong&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bike {
  constructor(model, color) {
    this.model = model;
    this.color = color;
    this.speed = 0;
  }

  start() {
    console.log(`${this.color} ${this.model} bike is started.`);
  }

  accelerate(speed) {
    this.speed += speed;
    console.log(`Accelerating to ${this.speed} km/h.`);
  }

  brake() {
    this.speed = 0;
    console.log("Brakes applied. Bike is stopped.");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;: An object is an instance of a class. Here, we can create two instances of the &lt;strong&gt;Bike&lt;/strong&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const classic350 = new Bike("Classic 350", "Black");
const bullet500 = new Bike("Bullet 500", "Desert Storm");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt;: Encapsulation is the concept of bundling data (attributes) and methods (functions) that operate on that data within a single unit, i.e., the class. In our example, the &lt;strong&gt;Bike&lt;/strong&gt; class encapsulates the bike's attributes (model, color, speed) and methods (start, accelerate, brake).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance&lt;/strong&gt;: Inheritance allows a class (subclass or derived class) to inherit the properties and behaviors of another class (superclass or base class). For example, we can create a &lt;strong&gt;RoyalEnfield&lt;/strong&gt; subclass that inherits from the &lt;strong&gt;Bike&lt;/strong&gt; class and adds specific features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class RoyalEnfield extends Bike {
  constructor(model, color, variant) {
    super(model, color);
    this.variant = variant;
  }

  displayDetails() {
    console.log(`Model: ${this.model}, Color: ${this.color}, Variant: ${this.variant}`);
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Polymorphism&lt;/strong&gt;: Polymorphism allows objects of different classes to be treated as objects of a common super class. It allows methods with the same name to have different implementations in different classes. In our example, the &lt;strong&gt;Bike&lt;/strong&gt; and &lt;strong&gt;RoyalEnfield&lt;/strong&gt; classes can both have an &lt;strong&gt;accelerate&lt;/strong&gt; method, but they might behave differently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classic350.start();        // Output: Black Classic 350 bike is started.
classic350.accelerate(60); // Output: Accelerating to 60 km/h.

bullet500.start();         // Output: Desert Storm Bullet 500 bike is started.
bullet500.accelerate(70);  // Output: Accelerating to 70 km/h.

const thunderbirdX = new RoyalEnfield("Thunderbird X", "Blue", "X Series");
thunderbirdX.start();      // Output: Blue Thunderbird X bike is started.
thunderbirdX.displayDetails(); // Output: Model: Thunderbird X, Color: Blue, Variant: X Series

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are some of the fundamental OOP concepts demonstrated through the example of a Royal Enfield bike. OOP provides a structured and organized way to model and interact with real-world entities in a software application.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Decrease the size of EBS volume in your EC2 instance</title>
      <dc:creator>Ramesh0807</dc:creator>
      <pubDate>Mon, 21 Nov 2022 19:42:09 +0000</pubDate>
      <link>https://dev.to/ramesh0807/decrease-the-size-of-ebs-volume-in-your-ec2-instance-4mh2</link>
      <guid>https://dev.to/ramesh0807/decrease-the-size-of-ebs-volume-in-your-ec2-instance-4mh2</guid>
      <description>&lt;p&gt;How to decrease volume size? one of my friend ask me this question. &lt;/p&gt;

&lt;p&gt;You might be wondering, can we decrease EBS volume size? The answer is NO. It is impossible to decrease EBS volume size. When you have 100GB EBS and you decide to modify it into 30GB you will get error : &lt;strong&gt;The size of a volume can only be increased, not decreased&lt;/strong&gt;. That’s terrible …&lt;/p&gt;

&lt;p&gt;But don’t worry. We could also do the trick to decrease EBS volume size. However, it is not easy task as it is not a straightforward. Here is the trick :  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Snapshot the volume&lt;/li&gt;
&lt;li&gt;Create a new smaller EBS volume&lt;/li&gt;
&lt;li&gt;Attach the new volume&lt;/li&gt;
&lt;li&gt;Format the new volume&lt;/li&gt;
&lt;li&gt;Mount the new volume&lt;/li&gt;
&lt;li&gt;Copy data from old volume to the new volume&lt;/li&gt;
&lt;li&gt;Prepare the new volume&lt;/li&gt;
&lt;li&gt;Detach and unmount old volume&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Getting started&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s exercise.&lt;/p&gt;

&lt;p&gt;Assume we have :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance named my-instance in &lt;code&gt;ap-southeast-1a&lt;/code&gt; zone&lt;/li&gt;
&lt;li&gt;100GB EBS volume size named &lt;code&gt;old-volume&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We wish to decrease into 30GB and name it &lt;code&gt;new-volume&lt;/code&gt;
We would need to shutdown the instance to prevent inconsistencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create a new smaller EBS volume&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Make sure instance is shutdown&lt;/li&gt;
&lt;li&gt; Go to Elastic Block Store Volumes&lt;/li&gt;
&lt;li&gt; Click Create Volume&lt;/li&gt;
&lt;li&gt; Choose the same volume type same with your old volume&lt;/li&gt;
&lt;li&gt; Enter your desired size; In our case 30.&lt;/li&gt;
&lt;li&gt; Choose availability zone; The volume will be available to instance in the same availability zone, which is ap-southeast-1a .&lt;/li&gt;
&lt;li&gt; Add tag with Key : Name and value : new-volume&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TOC-5FBo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s853111n25zgm01x4wxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TOC-5FBo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s853111n25zgm01x4wxj.png" alt="Alt Text" width="720" height="418"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Attach the new volume&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right click on the new volume.&lt;/li&gt;
&lt;li&gt;Click Attach Volume.&lt;/li&gt;
&lt;li&gt;Choose instance name my-instance .&lt;/li&gt;
&lt;li&gt;Click Attach.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We could start the instance and login to SSH. List all available volume with &lt;code&gt;lsblk&lt;/code&gt;. The new volume is in &lt;code&gt;/dev/xvdf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Format the new volume&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check whether the volume have any data or not using command &lt;code&gt;sudo file -s /dev/xvdf&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;If it is displaying &lt;code&gt;/dev/xvdf: data&lt;/code&gt;, it means the volume is empty. We could format the volume.&lt;/li&gt;
&lt;li&gt;If it is displaying other than above output, it means the volume have data. DO NOT format the volume if you saw this output.&lt;/li&gt;
&lt;li&gt;Format the volume using command &lt;code&gt;sudo mkfs -t ext4 /dev/xvdf&lt;/code&gt; .&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Mount the new volume&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Create directory to mount using command &lt;code&gt;sudo mkdir /mnt/new-volume&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt; Mount new volume into directory using command &lt;code&gt;sudo mount /dev/xvdf /mnt/new-volume&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; Check volume with command &lt;code&gt;df -h&lt;/code&gt;; The new volume should be mounted now.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Copy data from old volume to the new volume&lt;/strong&gt;  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Use rysnc to copy from old volume to the new volume &lt;code&gt;sudo rsync -axv / /mnt/new-volume/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; Relax and wait until it’s finished. Get a coffee!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Prepare new volume&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install grub on new-volume using command &lt;code&gt;sudo grub-install --root-directory=/mnt/new-volume/ --force /dev/xvdf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Unmount new-volume &lt;code&gt;sudo umount /mnt/new-volume&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;UUID&lt;/strong&gt; using command &lt;code&gt;blkid&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;Copy UUID from &lt;code&gt;/dev/xvda1&lt;/code&gt; (paste anywhere to backup this &lt;strong&gt;UUID&lt;/strong&gt;); This is your old &lt;strong&gt;UUID&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use tune2fs to replace UUID &lt;code&gt;sudo tune2fs -U COPIED_UUID /dev/xvdf&lt;/code&gt;; COPIED_UUID is the string value from point 4.&lt;/li&gt;
&lt;li&gt;Check the system label from old-volume using command &lt;code&gt;sudo e2label /dev/xvda1&lt;/code&gt; ; It will display string like cloudimg-rootfs .&lt;/li&gt;
&lt;li&gt;Replace new-volume label with old-volume label using command &lt;code&gt;sudo e2label /dev/xvdf cloudimg-rootfs&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;We can logout SSH now.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Detach old volume&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 1.  Stop instance `my-instance`
 2.  Detach `old-volume`
 3.  Detach `new-volume`
 4.  Attach new-volume to `/dev/sda1`
 5.  Start instance my-instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--67lhY-f4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40xk60v1g3ypvrkiofas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--67lhY-f4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40xk60v1g3ypvrkiofas.png" alt="Alt Text" width="880" height="246"&gt;&lt;/a&gt;&lt;br&gt;
     After we finish all steps above, we could check our instance by login into SSH.&lt;/p&gt;

&lt;p&gt;We could delete &lt;code&gt;old-volume&lt;/code&gt; and &lt;code&gt;snapshot-old-volume&lt;/code&gt; if our system works correctly. I prefer to keep snapshot for a week / month before deleting it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We cannot straightforward decreasing the size of EBS volume. All we can do is to create a new smaller volume.&lt;/p&gt;

&lt;p&gt;Hope it’s help!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Springboot version upgrade - my sql error</title>
      <dc:creator>Ramesh0807</dc:creator>
      <pubDate>Mon, 05 Oct 2020 14:36:17 +0000</pubDate>
      <link>https://dev.to/ramesh0807/springboot-version-upgrade-my-sql-error-50jh</link>
      <guid>https://dev.to/ramesh0807/springboot-version-upgrade-my-sql-error-50jh</guid>
      <description>&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/64206933/springboot-version-upgrade-my-sql-error"&gt;https://stackoverflow.com/questions/64206933/springboot-version-upgrade-my-sql-error&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>why need Scheduler?</title>
      <dc:creator>Ramesh0807</dc:creator>
      <pubDate>Fri, 11 Sep 2020 04:49:05 +0000</pubDate>
      <link>https://dev.to/ramesh0807/why-need-scheduler-19nl</link>
      <guid>https://dev.to/ramesh0807/why-need-scheduler-19nl</guid>
      <description>&lt;p&gt;Importance of switching on/ off the instance using a scheduler: In our early days, we were running our instances 24/7. One fine day we realized that we needed the instances to be up and running only for 10-12 hours per day i.e during our normal working hours. Thereby we were paying unnecessarily for the unused 12-14 hours.&lt;br&gt;
Our first approach was to turn instances on/off manually, but we later realized that this was prone to human errors. Additionally, as we were expanding, the manual effort required to turn them on/off was quite high and unnecessary too.&lt;br&gt;
With all this in mind we moved on to schedulers and this step has given us a huge cost saving of around 70 %(approximately) and also saves us approximately 10 man-hours per week.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scheduler:&lt;/strong&gt;&lt;br&gt;
    The Scheduler is a solution that enables customers to easily configure custom start and stop schedules for their Amazon EC2. The solution is easy to deploy and can help reduce operational costs for both development and production environments. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normal instance scheduler&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Scheduler implementation in IaaS(Infrastructure as a service):&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dxoxG3gC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/15og321nkxbd3vskkfxx.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dxoxG3gC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/15og321nkxbd3vskkfxx.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
    • When we create an instance on EC2, a unique instance ID gets created and this doesn’t change throughout the life of the instance. &lt;br&gt;
    • EC2 instance id is passed to the lambda function to start/stop EC2 instance as per schedule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scheduler implementation in PaaS(Platform-as-a-service):&lt;/strong&gt;&lt;br&gt;
    • AWS Elastic Beanstalk Environment has a unique id for each application (which is different from the instance id).&lt;br&gt;
    • Initially we configured our scheduler in the same way as Iaas i.e scheduler pointing to the instance ID. However, we faced our 1st challenge when we deployed a new version of our application.&lt;br&gt;
&lt;strong&gt;New way of implementation for scheduler (PaaS):&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J9Fhvmrk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kcw5yzfectmn34mmjfqy.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J9Fhvmrk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kcw5yzfectmn34mmjfqy.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
    • Due to the deployment a new instance ID had got generated but the scheduler was pointing to the old instance ID. Hence the scheduler didn’t work. &lt;br&gt;
    • We tackled this issue by using the environment ID instead of Instance ID. This way the scheduler was always pointing to the intended environment id.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components of the solution:&lt;/strong&gt;&lt;br&gt;
    1. Cloud watch - triggers the script to start and stop the services as per schedule&lt;br&gt;
    2. Lambda function - executes the script file&lt;br&gt;
    3. Cloudwatch - stores the log files&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The benefit of new solution:&lt;/strong&gt;&lt;br&gt;
    1. Customers who use this solution to run instances only during regular business hours can save up to 70%(approximately) compared to running those instances 24 hours a day.&lt;br&gt;
    2. Easy to configure and monitor,&lt;br&gt;
    3. using the same trigger script both Environment and EC2 instance can be started/stopped&lt;br&gt;
    4. No need to configure DynamoDb&lt;br&gt;
    5. No manual efforts required and hence a lot of time saved from a Programmer’s perspective&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge from usability:&lt;/strong&gt;&lt;br&gt;
    •  Server/Application should be up and running during the standard office hours on all working days. i.e Monday to Friday 9 AM to 10 PM IST. &lt;br&gt;
    • Hence 2 lambda functions have been created - one to start the server and the other to stop the server. Appropriate log files have been created for monitoring servers on and off times.&lt;br&gt;
    • So if someone wants to use the application during the scheduled downtime, the application needs to be brought up manually by logging in to AWS. To make it easier we are trying to create a mobile service to perform the same on Adhoc basis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
    • Input parameters to the cloud watch/lambda utilities should be determined based on the implementation model i.e Iaas or Paas. Only this will ensure the successful functioning of the scheduler.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>python</category>
    </item>
  </channel>
</rss>
