Saturday, February 29, 2020

Getting Started with Apache Solr on Windows


This Post will explain about what is Apache Solr and how to do the setup on windows environment, Basic Apache Solr commands

What is Apache Solr?

Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene

Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world's largest internet sites

We need the Java Runtime Environment (JRE) version 1.8 or higher to install the Apache Solr

Check the java version using the below command

Java -version

Step 1:

Download the Apache latest version from this link, either source or binary
Download Apache Solr

Apache solr-8.4.1.zip


Step 2:

Unzip the downloaded one and set the path, inside environment variables, check my previous post how to set the environment variables

After Setting the env varibles, use the below command to start the solr


Step 3:

Go to the location, where it has unzipped up to bin folder

solr start

Will start the solr and give the message stating solr has been started

Know the status of the solr use the below command

solr status

create a core that uses a data-driven schema which tries to guess the correct field type when you add documents to the index.

solr create -c movies

Step 4:

Use the below link in the browser, to check about created core and other details

try with http://localhost:8983/


Step 5:

Stop the Solr

solr stop -all

Thank you for viewing this post , just we created the core, Next post will explain , how to do the indexing and search and many more features, which is provided by Apache Solr.

Sunday, February 23, 2020

How Apache Kafka is Better than any other traditional messaging brokers(Active MQ,JMS,Camel,IBM MQ)


1. Kafka is a distributed streaming platform
2. Kafka stores all the messages before sending or after successufully received by subscriping applications.
3. Kafka Run as a cluster on one or more servers that can be available on multiple datacenters.
4. Kafka is client centric and it has fair distribution of related messages to consumers and it is extreamly fast and scalable broker
5. Kafka has Horizontally scalable, by adding more partitions
6. Kafka does not degrade performance , adding of new consumers
7. Kafaka uses one destination type called topic, which internally combines both publish-subscribe and point-to-point
8. Kafka message is key-value pair. payload of the message sent as the value.
9. Kafaka cients are responsible for replaying failed messages
10. Kafka retains messages, it is possible for clients to retrieve any message, providing option for re-processing of all messages.

Traditional messasing brokers either don't persist messages at all. and it will store only until they consumed and acknowledged.
Traditional messaging brokers like imperative programming, An event is occurred and our code is notified of that event. it is tightly coupled.

You can Read Apache Kafka for more information about apache kafka




Monday, October 28, 2019

Jasper Reports export to EXCEL, CSV and PDF Using JRXML Java and My SQL



This Post will explain , How to export different formats using Jasper and Jrxml using java

Step 1: Download Download Jasper Studio
or I Report Designer


Step 2 : Design your page by providing connection details and query details and what columns needs to be display in PDF/excel/CSV


Step 3: Your design Page details can be mentioned in Summary Band.






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
   
  
  
   
   
  
  
   
   
  
  
   
   
  
  
   
   
  
  
   
  
  
   
  
  
   
  
  
   
  
 
 
  
 
 
  
  
 
 
  
  
 
 
  
  
 
 
  
  
 
 
  
   
   
    
     
     
     
     
     
    
    
     
      
     
     
      
      
      
       
        
        
       
      
      
      
       
        
        
       
      
     
     
      
      
      
       
        
        
       
      
      
      
       
        
        
       
      
     
     
      
      
      
       
        
        
       
      
      
      
       
        
        
       
      
     
     
      
      
      
       
        
        
       
      
      
      
       
        
        
       
      
     
    
   
  
 






Step 4: Once design completes , then it is time to write java class to export into different formats


Step 5: Excel report Generation





package arrayListTest;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;

import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.export.SimpleCsvExporterConfiguration;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
import net.sf.jasperreports.export.SimpleWriterExporterOutput;
import net.sf.jasperreports.export.SimpleXlsReportConfiguration;

public class GenerateMultipleReportsFromJasper {
 
  public static void main(String[] args) {

  //Jrxml file source
  String sourceFileName = "C:\\Users\\Siva\\JaspersoftWorkspace\\csvpdf\\csv_export.jrxml";
  //destination file location
  String outXlsName = "C:\\Users\\Siva\\JaspersoftWorkspace\\csvpdf\\test.xls";
  //If we want to pass any parameters to jasper report, then we can use this map
  HashMap xlsParams = new HashMap();
  Connection con = null;
  try {
    Class.forName("com.mysql.jdbc.Driver");
    // here employee is database name, root is username and password
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee", "root", "root");
    JasperReport report = JasperCompileManager.compileReport(sourceFileName );
    JasperPrint xlsPrint = JasperFillManager.fillReport(report, xlsParams, con);
    JRXlsExporter xlsExporter = new JRXlsExporter();
    xlsExporter.setExporterInput(new SimpleExporterInput(xlsPrint));
    xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outXlsName));
    SimpleXlsReportConfiguration xlsReportConfiguration = new SimpleXlsReportConfiguration();
    xlsReportConfiguration.setOnePagePerSheet(false);
    xlsReportConfiguration.setRemoveEmptySpaceBetweenRows(true);
    xlsReportConfiguration.setDetectCellType(false);
    xlsReportConfiguration.setWhitePageBackground(false);
    xlsExporter.setConfiguration(xlsReportConfiguration);
    xlsExporter.exportReport();
  } catch (Exception e) {
      System.out.println(e);
    }
    finally{
      try{
 if(con != null){
    con.close();
 }
 
      }
    catch(Exception ex){
 }
    }
  }

}


Step 6: CSV Generation




HashMap csvParamsMap = new HashMap();
String outcsvName = "C:\\Users\\Siva\\JaspersoftWorkspace\\csvpdf\\test.csv";
JasperReport report1 = JasperCompileManager.compileReport(sourceFileName );
JasperPrint jasperPrint = JasperFillManager.fillReport(report1, csvParamsMap, con);
JRCsvExporter exporter = new JRCsvExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleWriterExporterOutput(new File(outcsvName)));
SimpleCsvExporterConfiguration configuration = new SimpleCsvExporterConfiguration();
configuration.setWriteBOM(Boolean.TRUE);
configuration.setRecordDelimiter("\r\n");
exporter.setConfiguration(configuration);
exporter.exportReport();


Step 7: PDF Generation




HashMap pdfParamsMap = new HashMap();
String outPdfName = "C:\\Users\\Siva\\JaspersoftWorkspace\\csvpdf\\test.pdf";
JasperReport report2 = JasperCompileManager.compileReport(sourceFileName );
JasperPrint jasperPrint2 = JasperFillManager.fillReport(report2, pdfParamsMap, con);
JRPdfExporter pdfExporter = new JRPdfExporter();
pdfExporter.setExporterInput(new SimpleExporterInput(jasperPrint2));
pdfExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outPdfName));
SimplePdfExporterConfiguration pdfConfiguration = new SimplePdfExporterConfiguration();
pdfConfiguration.setCreatingBatchModeBookmarks(true);
pdfExporter.setConfiguration(pdfConfiguration);




Step 8: Required jar file to execute this program



1. Itext 2.1.7.jar
2. commons-beanutils-1.9.2.jar
3. commons-logging-1.2.jar
4. commons-collections-3.2.1.jar
5. commons-lang-2.6.jar
6. commons-digester-1.6.jar
7. jasperreports-6.2.0.jar
8. mysql-connector-java-5.1.40.jar
9. poi-ooxml-3.16.jar
10. poi-3.12.jar



Step 9: Once We downloaded all jars then add into java build path.

Step 10: This is how we can export different format using jasper jrxml and Java.


Saturday, August 10, 2019

Getting started with Kubernetes and Install Kubernetes on Windows , Tools for Kubernetes Cluster



1. What is Kubernetes?
It is an open source system for automating deployment, scaling and managing containerized applications

How to install Kubernetes?

1. Install Kube control(kubectl) on Windows
2. kubectl (kubernet command control tool) , used to run the commands in kubernetes clusters.
3. Before install, we have to make sure each client version has to work with minor difference with master
For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master

4. Download from the given link Download Kubernetes
5. Add the binary in to your PATH.(System - Environment Variables)
6.Check the version using kubectl version

We can create sample cluster online using following link

Online interactive kubernetes cluster

Popular tools for kubernetes clusters
1. (Mini Kube)
2. Google Kubernetes Engine (GKE)
3. Amazon Elastic Kubernetes Service (EKS):
4. Azure Kubernetes Service (AKS)

AddToAny

Contact Form

Name

Email *

Message *