#!/bin/bash
echo hello $1 $2
on command line :./startup.sh dinesh donthaoutput:hello dinesh dontha#!/bin/bash
echo hello $1 $2
on command line :./startup.sh dinesh donthaoutput:hello dinesh donthatail -100f catalina.out
let's say we want to run the latest current running logs with last 100 lines, then you should use the above command.
cd <specific folder>
useful to change to mentioned directory
cd ..
useful to change back to parent directory, one level down
mkdir <dir_name>
creates a new directory with given name <dir_name>
mkdir -p <dir1/dir2/dir3>
creates the directory structure, which fails to do without -p option
rm -r <dir1/dir2/dir3>
removes the complete directory structure, regardless of number of internal directories, which fails to remove without -r option.
I would recommend different installation process on mac rather than installing the nodejs using brew command line.
../ docs/ 05-Jan-2017 21:30 - win-x64/ 05-Jan-2017 21:04 - win-x86/ 05-Jan-2017 21:23 - SHASUMS256.txt 05-Jan-2017 23:33 3865 SHASUMS256.txt.asc 05-Jan-2017 23:33 4369 SHASUMS256.txt.sig 05-Jan-2017 23:33 287 node-v6.9.4-aix-ppc64.tar.gz 05-Jan-2017 21:08 17397618 node-v6.9.4-darwin-x64.tar.gz 05-Jan-2017 21:29 12041778 node-v6.9.4-darwin-x64.tar.xz 05-Jan-2017 21:30 8316788 node-v6.9.4-headers.tar.gz 05-Jan-2017 21:35 476961 node-v6.9.4-headers.tar.xz 05-Jan-2017 21:35 346992 node-v6.9.4-linux-arm64.tar.gz 05-Jan-2017 20:52 13216193 node-v6.9.4-linux-arm64.tar.xz 05-Jan-2017 20:52 8413528 node-v6.9.4-linux-armv6l.tar.gz 05-Jan-2017 21:27 13058040 node-v6.9.4-linux-armv6l.tar.xz 05-Jan-2017 21:33 8291812 node-v6.9.4-linux-armv7l.tar.gz 05-Jan-2017 21:03 13040155 node-v6.9.4-linux-armv7l.tar.xz 05-Jan-2017 21:05 8304476 node-v6.9.4-linux-ppc64.tar.gz 05-Jan-2017 20:49 13994448 node-v6.9.4-linux-ppc64.tar.xz 05-Jan-2017 20:50 8522364 node-v6.9.4-linux-ppc64le.tar.gz 05-Jan-2017 20:48 13749594 node-v6.9.4-linux-ppc64le.tar.xz 05-Jan-2017 20:48 8655784 node-v6.9.4-linux-s390x.tar.gz 05-Jan-2017 20:46 14201628 node-v6.9.4-linux-s390x.tar.xz 05-Jan-2017 20:46 8933844 node-v6.9.4-linux-x64.tar.gz 05-Jan-2017 20:50 13928019 node-v6.9.4-linux-x64.tar.xz 05-Jan-2017 20:51 9348020 node-v6.9.4-linux-x86.tar.gz 05-Jan-2017 20:52 13411488 node-v6.9.4-linux-x86.tar.xz 05-Jan-2017 20:53 8935060 node-v6.9.4-sunos-x64.tar.gz 05-Jan-2017 21:10 14679106 node-v6.9.4-sunos-x64.tar.xz 05-Jan-2017 21:11 9442348 node-v6.9.4-sunos-x86.tar.gz 05-Jan-2017 23:31 13617149 node-v6.9.4-sunos-x86.tar.xz 05-Jan-2017 23:31 8765124 node-v6.9.4-win-x64.7z 05-Jan-2017 21:05 6868142 node-v6.9.4-win-x64.zip 05-Jan-2017 21:05 12239442 node-v6.9.4-win-x86.7z 05-Jan-2017 21:24 5982803 node-v6.9.4-win-x86.zip 05-Jan-2017 21:24 11026266 node-v6.9.4-x64.msi 05-Jan-2017 21:06 12791808 node-v6.9.4-x86.msi 05-Jan-2017 21:24 11489280 node-v6.9.4.pkg 05-Jan-2017 21:24 15526075 node-v6.9.4.tar.gz 05-Jan-2017 21:31 26379683 node-v6.9.4.tar.xz 05-Jan-2017 21:32 15519264
Just a quick introduction, we can create Kafka Topic. using command line utility and also using programming APIs.
This post shows command line utility which help us in creating the Kafka Topic.
For your information, under /bin folder of Kafka installation, there are many Kafka Utilities available for various uses, one of which to kafka-topics.sh helps to create topics, describe topics & other topic related stuff.
Before executing the topic command as below, ensure your Zookeeper Server and Kafka Cluster (same order - start Zookeeper 1st then Kafka Cluster service next) has already been started.
Lets say Kafka cluster is having one node with its Kafka Service node running at a default port 9092 & we are trying to create a topic named error-events
$ bin/kafka-topics.sh --create --topic error-events --bootstrap-server localhost:9092Console Output:
Topic created.
To ensure the topic creation, we can describe the topic:
$ bin/kafka-topics.sh --describe --topic error-events --bootstrap-server localhost:9092
Topic:error-events PartitionCount:1 ReplicationFactor:1 Configs:
Topic: error-events Partition: 0 Leader: 0 Replicas: 0 Isr: 0
It prints all the information related to given kafka topic - like partition count, replicator factor, replicas, in-sync replicas (Isr), Leader ...
First Way:
You can use mvn option -U : which forces the maven to download the dependency into local repository (.m2 folder)
Eg:
mvn clean package -U
Second Way:
Use purge-local-repository
Eg:
mvn dependency:purge-local-repository clean package
Third Way:
You can manually directly delete the .m2 folder in computers home directory (like in linux - mac, ~)
you can use GSON annotation @SerializedName annotation for using a different names for serialized fields.
Maven Dependency Needed:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency> For Example:
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
public class GsonExposeAnnotationTest {
public static void main(String[] args) {
Student student = new Student("Dinesh", "ROLL123", "Hyderabad - 500081");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(student));
}
}
class Student {
@SerializedName("student-name")
String name;
@SerializedName("student-rollno")
String rollNo;
@SerializedName("student-address")
String address;
public Student(String name, String rollNo, String address) {
this.name = name;
this.rollNo = rollNo;
this.address = address;
}
} Output: Serialised output - fields name are different than in POJO { "student-name": "Dinesh", "student-rollno": "ROLL123", "student-address": "Hyderabad - 500081" }
You can use @Expose annotation to exclude or include the fields using GSON library. By default, @Expose serialize & deserialize attributes have true. So you can mention @Expose directly, which intends @Expose(serialize = true, deserialize = true)
Maven Dependency Need: Add this dependency in your pom.xml file.
For Example:<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
public class GsonExposeAnnotationTest {
public static void main(String[] args) {
Customer customer = new Customer("Dinesh", "CID124", new Integer(12));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(customer));
gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
System.out.println(gson.toJson(customer));
}
}
class Customer {
@Expose(serialize = true, deserialize = true)
public String customerName;
@Expose(serialize = true, deserialize = true)
public String customerId;
@Expose(serialize = false, deserialize = false)
public Integer totalAssets;
public Customer(String customerName, String customerId, Integer totalAssets) {
this.customerName = customerName;
this.customerId = customerId;
this.totalAssets = totalAssets;
}
}
Input:{"customerName": "Dinesh", "customerId": "CID124", "totalAssets": 12 }output: Only exposed fields are in the seen in the output after serialisation.{ "customerName": "Dinesh", "customerId": "CID124" }
You can use print () function in python to output something in python.
CRON expressions are mainly used for scheduling tasks, which should run frequently at a fixed rate, lets say, running a task every day at mid night 12'0 Clock, running a task every hour & like wise.
For Example, An Online shopping cart application might have many schedulers that schedule the tasks, for instance, once an order is placed successfully by a customer, a shipping order scheduler might processes these successful orders placed in previous hour or before some time.
A typical CRON expression: "0/5 * * ? * *"
CRON expression basically consists of 7 components. Each component will have range of allowed values, Allowed special characters. For example, "Seconds" component will have range of values allowed from 0 to 59.
CRON expression components:
"Seconds" "Minutes" "Hours" "Day of month" "month" "Day of week" "Year"All are mandatory parameters, except "Year".
"Seconds" - a mandatory parameter
Range of values: 0-59Allowed characters , - * /
Examples: 10,20 executes at 10th second and 20th second
* executes at every second 0/5 executes every 5 seconds starting from 0th second"Minutes" - a mandatory parameterRange of values: 0-59Allowed characters , - * /Examples:10,20 executes at 10th minute and 20th minute* executes at every minute0/5 executes every 5 minutes starting from 0th minute"Hours" - a mandatory parameterRange of values: 0-23Allowed characters , - * /Examples:10,20 executes at 10th hour and 20th hour* executes at every hour0/5 executes every 5 hours starting from mid night 12:00 AM"Day of month" - a mandatory parameterRange of values: 1-31Allowed characters , - * ? / L W CExamples:10,20 executes at 10th day and 20th day* executes at every day1/5 executes every 5 days starting from first dayL represents the last day of the month. L is allowed only with "Day of month"& "Day of week".L represents 31st in Jan, 28th in Feb (non-leap years)W represents the nearest week-day. Only allowed to use when it is a single day,not allowed with range of values.12Wsay if 12th day of the month is Saturday, it will trigger on 11th day (Friday),if 12th day is Sunday, it will trigger on 13th day (Monday),if 12th day is a Monday, as it is weekday, it will trigger on 12th day (Monday)C represents the calendar. Only allowed for "Day of month" &"Day of week" components.Values are calculated against an associated calendar if any.If no calendar associated, if it is declared like5C represents the first day included by the calendar on or after the 5th."Month" - a mandatory parameterRange of values: 0-11 or JAN-DECAllowed characters , - * /Examples:1,2 executes at FEB & MAR monthsFEB,MAR executes at FEB & MAR months* executes at every month"Day of Week" - a mandatory parameterRange of values: 0-11 or JAN-DECAllowed characters , - * ? / L C #L represents the last day of the month. L is allowed only with "Day of month"& "Day of week"1-7 (1 - sun, 2- mon, 3-tues, 4-wed, 5- thur, 6-fri, 7-sat)6L represents last Friday of the month.C represents the calendar. Only allowed for "Day of month"& "Day of week" components.Values are calculated against an associated calendar if any.If no calendar associated, if it is declared like1C represents the first day included by the calendar on or after Sunday.7C represents the first day included by the calendar on or after Saturday.# is used to represent a single day, like nth XXX day.Only allowed for "Day of week".7#2 represents the 2nd Saturday of the month."Year" - an optional parameterRange of values: empty or 1970-2099Allowed characters , - * /Examples:2000-2010 executes for range of years from 2000 to 20102000,2006 executes for years 2000 and 2006* executes at every yearExamples with all components combined:
| 0 0 12 * * ? | Fire at 12:00 PM (noon) every day |
| 0 20 10 ? * * | Fire at 10:20 AM every day |
| 0 15 11 * * ? | Fire at 11:15 AM every day |
| 0 15 10 * * ? * | Fire at 10:15 AM every day |
| 0 20 20 * * ? 2010 | Fire at 08:20 PM every day during the year 2010 |
| 0 * 14 * * ? | Fire every minute starting at 2:00 PM and ending at 2:59 PM, every day |
| 0 0/5 14 * * ? | Fire every 5 minutes starting at 2:00 PM and ending at 2:55 PM, every day |
| 0 0/5 14,18 * * ? | Fire every 5 minutes starting at 2:00 PM and ending at 2:55 PM, AND fire every 5 minutes starting at 6:00 PM and ending at 6:55 PM, every day |
| 0 0-5 16 * * ? | Fire every minute starting at 4:00 PM and ending at 4:05 PM, every day |
| 0 10,22 14 ? 3 FRI | Fire at 2:10 PM and at 2:22 PM every Friday in the month of March |
| 0 15 10 ? * MON-FRI | Fire at 10:15 AM every Monday, Tuesday, Wednesday, Thursday and Friday |
| 0 15 10 15 * ? | Fire at 10:15 AM on the 15th day of every month |
| 0 15 10 L * ? | Fire at 10:15 AM on the last day of every month |
| 0 15 10 ? * 7L | Fire at 10:15 AM on the last Saturday of every month |
| 0 15 10 ? * 7L | Fire at 10:15 AM on the last Saturday of every month |
| 0 15 10 ? * 7L 2002-2004 | Fire at 10:15 AM on every last Saturday of every month during the years 2002, 2003 and 2004 |
| 0 15 10 ? * 6#3 | Fire at 10:15 AM on the third Friday of every month |
| 0 0 12 1/5 * ? | Fire at 12 PM (noon) every 5 days every month, starting on the first day of the month |
| 0 6 6 6 6 ? | Fire every June 6 at 6:06 AM |
How to use CRON expression in spring scheduling @Scheduled annotation?
As we know that, firstly, we need to enable scheduling using @EnableScheduling
and use @Scheduled annotation on tasks.
Full example: Spring boot scheduling example
Example:
@Scheduled(cron = "0/5 * * ? * *")
public void reportCurrentTime() throws InterruptedException {
//Thread.sleep(6000l);
logger.info(formatter.format(new Date()));
}
| Payment_No | Customer | Customer_Id | Payments | Policy_Type | Payment_date |
| 00001 | Ramesh | 1 | 1000 | 01 | 2018-02-01 03:26:30 |
| 00002 | Rajesh | 2 | 10000 | 02 | 2018-02-01 03:27:00 |
| 00003 | Ramesh | 1 | 3000 | 02 | 2018-02-01 03:30:33 |
| 00004 | Geeta | 3 | 2500 | 01 | 2018-02-01 03:28:31 |
| Customer_Id | Total Payment |
| 1 | 4000 |
| 2 | 10000 |
| 3 | 2500 |
| Customer_Id | Total Payment | List Of Policies |
| 1 | 4000 | 01,02 |
| 2 | 10000 | 02 |
| 3 | 2500 | 01 |
| Customer_Id | Total Payment | List Of Policies |
| 1 | 4000 | 01^^^02 |
| 2 | 10000 | 02 |
| 3 | 2500 | 01 |
| Customer_Id | Total Payment | List Of Policies |
| 1 | 4000 | 02^^^01 |
| 2 | 10000 | 02 |
| 3 | 2500 | 01 |
| Customer_Id | Total Payment | List Of Policies |
| 1 | 4000 | 02,01 |
| 2 | 10000 | 02 |
| 3 | 2500 | 01 |
| Payment_No | Customer | Customer_Id | Payments | Policy_Type | Payment_date |
| 00001 | Ramesh | 1 | 1000 | 01 | 2018-02-01 03:26:30 |
| 00002 | Rajesh | 2 | 10000 | 02 | 2018-02-01 03:27:00 |
| 00003 | Ramesh | 1 | 3000 | 02 | 2018-02-01 03:30:33 |
| 00004 | Geeta | 3 | 2500 | 01 | 2018-02-01 03:28:31 |
| Customer_Id | Total Payment | List Of Policies | Payment Date |
| 1 | 4000 | 02,01 | 2018-02-01 03:26:30,2018-02-01 03:30:33 |
| 2 | 10000 | 2 | 2018-02-01 03:27:00 |
| 3 | 2500 | 1 | 2018-02-01 03:28:31 |
| Customer_Id | Total Payment | List Of policies | Payment Date |
| 2 | 10000 | 02 | 2018-02-01 03:27:00 |
| 3 | 2500 | 01 | 2018-02-01 03:28:31 |
| 1 | 4000 | 02,01 | 2018-02-01 03:26:30,2018-02-01 03:30:33 |
| Customer_Id | Total Payment | List Of policies | Payment Date |
| 1 | 4000 | 02,01 | 2018-02-01 03:26:30,2018-02-01 03:30:33 |
| 2 | 10000 | 02 | 2018-02-01 03:27:00 |
| 3 | 2500 | 01 | 2018-02-01 03:28:31 |
| Customer_Id | Total Payment | List Of policies | Payment Date |
| 1 | 4000 | 02,01 | 2018-02-01 03:26:30,2018-02-01 03:30:33 |
| 3 | 2500 | 01 | 2018-02-01 03:28:31 |
| 2 | 10000 | 02 | 2018-02-01 03:27:00 |
| Customer_Id | Total Payment | List Of policies | Payment Date |
| 3 | 2500 | 1 | 2018-02-01 03:28:31 |
| 2 | 10000 | 2 | 2018-02-01 03:27:00 |
| 1 | 4000 | 02,01 | 2018-02-01 03:26:30,2018-02-01 03:30:33 |