This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.joda.time.DateTime | |
import org.joda.time.format.DateTimeFormat | |
import org.json4s._ | |
import org.json4s.native.JsonMethods._ | |
val datePattern = "yyyy-MM-dd hh:mm:ss.SSSSSS" | |
val s = """{"timestamp": "2016-09-29 11:31:13.247772", "domain": "d1", "filePath": "s3://..."}""" | |
case class Event(domain : String, filePath : String, timestamp : Long) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import boto.emr | |
import time | |
import sys | |
region = sys.argv[1] | |
clusterId = sys.argv[2] | |
def getStatus(cluster_id): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elasticsearch import Elasticsearch | |
es = Elasticsearch(hosts=['es-host:9200'], timeout=600) #long timeout for the restore operation | |
snapshotName='index_name_20151012140502' | |
alias = es.indices.get_alias('index_name').keys()[0] if es.indices.exists_alias(name='index_name') else '' | |
indices = filter(lambda x: x.startswith('index_name'), es.indices.get_aliases()) | |
indices.sort() | |
print 'restore repository' | |
es.snapshot.restore(repository='repository_name', snapshot=snapshotName, body ='{ "ignore_unavailable": "true", "include_global_state": false}', wait_for_completion=True) | |
if (len(alias) > 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.amazonaws.auth.{BasicAWSCredentials, InstanceProfileCredentialsProvider} | |
import com.amazonaws.services.ec2.AmazonEC2Client | |
import com.amazonaws.services.ec2.model._ | |
import com.amazonaws.util.Base64 | |
trait Ec2Utils extends Logging { | |
val AWS_ACCESS_KEY_ID: String | |
val AWS_SECRET_ACCESS_KEY: String | |
val instanceProfile = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd /mnt/ | |
apt-get -y update | |
apt-get -y install openjdk-7-jre | |
apt-get -y install zip | |
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.1.1.zip && unzip elasticsearch-1.1.1.zip && /mnt/elasticsearch-1.1.1/bin/plugin -install mobz/elasticsearch-head | |
/mnt/elasticsearch-1.1.1/bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.1.1 | |
echo " network.bind_host: $(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')" >> /mnt/elasticsearch-1.1.1/config/elasticsearch.yml | |
screen -dmS new_screen sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pop emr cluster with spark job to execute | |
aws emr create-cluster --name "<cluster name>"\ | |
--region us-east-1\ | |
--log-uri s3://<bucket>/logs/<cluster name>/\ | |
--enable-debugging\ | |
--release-label emr-4.0.0\ | |
--applications Name=Spark\ | |
--ec2-attributes KeyName=<keyname>\ | |
--use-default-roles\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance |