Skip to content

Instantly share code, notes, and snippets.

View onesuper's full-sized avatar

Dreamsome onesuper

View GitHub Profile
@onesuper
onesuper / yg-env.sh
Last active September 18, 2016 01:15
yg-env.sh
#!/usr/bin/env sh
#
# $ echo 'source path_to_env.sh' >> ~/.bashrc
# $ yg_install
KAFKA_HOST=bj2-storm03:9092
ES_HOST=bj2-storm03:9200
ZK_HOST=bj2-storm03:2181,bj2-storm04:2181,bj2-storm05:2181
STORM_LOG_HOME='/usr/local/storm-default/logs/'
TODAY=$(date '+%Y-%m-%d')
@onesuper
onesuper / backup.sh
Created October 9, 2016 03:22 — forked from nherment/backup.sh
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@onesuper
onesuper / spark-env.sh
Created October 11, 2016 06:16 — forked from berngp/spark-env.sh
Spark Env Shell for YARN - Vagrant Hadoop 2.3.0 Cluster Pseudo distributed mode.
#!/usr/bin/env bash
# This file contains environment variables required to run Spark. Copy it as
# spark-env.sh and edit that to configure Spark for your site.
#
# The following variables can be set in this file:
# - SPARK_LOCAL_IP, to set the IP address Spark binds to on this node
# - MESOS_NATIVE_LIBRARY, to point to your libmesos.so if you use Mesos
# - SPARK_JAVA_OPTS, to set node-specific JVM options for Spark. Note that
# we recommend setting app-wide options in the application's driver program.
public class RedisClient {
private JedisPool pool;
@Inject
public RedisClient(Settings settings) {
try {
pool = new JedisPool(new JedisPoolConfig(), settings.get("redis.host"), settings.getAsInt("redis.port", 6379));
} catch (SettingsException e) {
// ignore
@onesuper
onesuper / KafkaProducer.java
Created February 24, 2017 02:34 — forked from yaroncon/KafkaProducer.java
Kafka producer, with Kafka-Client and Avro
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.Encoder;
import org.apache.avro.io.EncoderFactory;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;