Skip to content

Instantly share code, notes, and snippets.

View anhtv08's full-sized avatar

Joey Trang anhtv08

View GitHub Profile
@anhtv08
anhtv08 / SpringBootDemoApplication.java
Created September 17, 2018 15:25
main class of spring boot app
package com.anhtv08.springbootdemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootDemoApplication.class, args);
@anhtv08
anhtv08 / HelloController.java
Created September 17, 2018 15:33
Rest Controller
package com.anhtv08.springbootdemo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello(){
@anhtv08
anhtv08 / SpringBootApplication.java
Created October 13, 2018 08:27
SpringBootApplication.java
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.springframework.boot.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
@anhtv08
anhtv08 / eureka-maven.pom
Created October 17, 2018 15:13
eureka-config.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.anhtv08</groupId>
<artifactId>spring-tutorials</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.anhtv08</groupId>
<artifactId>spring-tutorials</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
CASSANDRA_VERION=3.11
CASSANDRA_NODES=(
CASSANDRA_1 \
CASSANDRA_2 \
CASSANDRA_3
)
# setup cassandra 3.11
# assume you have docker installed.
keyspace: perftesting
keyspace_definition:
CREATE KEYSPACE perftesting WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': 3};
table: users
table_definition:
CREATE TABLE users (
def lambda_handler(event, context):
log.info(" evaluating tags of ec2 instance")
if not event:
log.info("event is not valid")
else:
evaluate_ec2_instance(ec2_client, event)
def evaluate_ec2_instance(ec2_client, event):
instance_id = event['detail']['instance-id']
instance_state = event['detail']['state']
'''
only perform this evaluation rule when starting an new instance
check if instance state is pending then try to perfrom evaluation
'''
if instance_state != 'pending':
log.info('current state : ' + instance_state)