Posts

Azure DevOps - CI/CD pipeline for container-based system

Image
Azure provides a set of flexible services designed to enable companies to more rapidly and reliably build and deliver products using Containers and DevOps practices. These services simplify provisioning and managing infrastructure, deploying application code, automating software release processes, and monitoring your application and infrastructure performance. In this post, we will learn how to modernize spring web application development by using containers and DevOps workflows. In this example, A Spring web app is built and deployed by Jenkins into an Azure Container Registry and Azure Kubernetes service. For a globally distributed database tier, Azure SQL Database is utilized. To monitor and troubleshoot application performance, Azure Monitor integrates with a Grafana instance and dashboard. Today modern application development uses continuous integration (CI) and continuous deployment (CD), we can more expeditiously build, test, and deploy services. This modern approach lets us rel

Java 8 Streams - Sum of all the items of the List

Example 1: Using  Collectors.summingInt() import java.util.Arrays ; import java.util.List ; import java.util.stream.Collectors ; public class Main { public static void main ( String [] args) { List < Integer > integers = Arrays . asList ( 2 , 9 , 10 , 8 , 4 , 7 ); Integer sum = integers .stream() .collect( Collectors . summingInt ( Integer ::intValue)); System . out .println( "Sum= " + sum ); } } Here, stream() method returns a sequential Stream with List as its source. summingInt() method returns a Collector that produces the sum of a integer.   Similarly, the Collectors class provides summingDouble() and summingLong().   Example 2: Using Stream.reduce()   import java.util.Arrays ; import java.util.List ; public class Main { public static void main ( String [] args) { List < Integer > integers = Arrays . asList ( 2 , 9 , 10 , 8 , 4 , 7 ); Integer sum = integers .stream() .reduce(

Learn Java 8 streams with an example - How to sort a list

  Example 1: Sort the List In the natural order import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class DriverClass { public static void main(String[] args) { List<String> list = Arrays. asList ( "H" , "A" , "Z" , "L" , "B" , "Y" , "M" , "a" , "c" ); list.stream(). sorted() .collect(Collectors. toList ()).forEach (System. out ::println); } } Output: A B H L M Y Z a c Example 2: Sort the List In the reverse Order import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; public class DriverClass { public static void main(String[] args) { List<String> list = Arrays. asList ( "H" , "A" , "Z" , "L" , "B" , "Y" , "M" , "a" , "c" ); li

Java 8 Streams - Finding largest & smallest element in an Array, List & Set

Example 1: Finding the largest element in an array import java.util.Arrays; /* Java Program to find the largest number from an Array. */ public class DriverClass { public static void main( String [] args) { int [] numbers = { 2 , 6 , 7 , 9 , 5 , 155 , 66 , 99 }; int largestNumber = Arrays.stream(numbers). max().getAsInt(); System.out.println( "Largest Number= " + largestNumber); } } Output: Largest Number= 155 Example 2: Finding the largest element in a List import java.util.Arrays; import java.util.Comparator; import java.util.List; /* Java Program to find the largest number from a List. */ public class DriverClass { public static void main( String [] args) { List < Integer > numbers = Arrays. asList( 2 , 6 , 7 , 9 , 5 , 155 , 66 , 99 ); int largestNumber = numbers.stream(). max(Comparator.comparing