Skip to content

Instantly share code, notes, and snippets.

View sarveshseri's full-sized avatar

Sarvesh Kumar Singh sarveshseri

View GitHub Profile

Lets assume that you have a cluster with the name - awesome_cluster.

How to enable a HDFS View

On a fresh Ambari cluster, we need to follow following steps to create the HDFS view.

Allow the superuser to impersonate other users.

Well... Ambari tries to impersonate the current logged in user with the superuser, and thus the simplest ( but not the best ) thing is to allow the superuser to imperonate all users. Similarily we also need to tell Ambari the name of the host from which the superuser can connect ( simplest is to allow all hosts ).

On Ambari dashboard go to Services > HDFS > Config > Advanced > Custom Core Site and add following new paramters

Fix corrupt file system

First of all switch to the hdfs user

sudo su hdfs
Check file system health
hdfs -fsck /
# or
hdfs fsck hdfs://hdfsHost:port/
@sarveshseri
sarveshseri / UniqueItemIDGen.scala
Last active March 25, 2016 02:20
Unique Id generator for models in Scala applications
import org.joda.time.DateTime
import scala.annotation.tailrec
import scala.util.Random
object RANStream {
val randomAlphaNumIterator = Random.alphanumeric.iterator
@tailrec
def getRandomString(length: Int, acc: String = ""): String = {
import scala.collection.mutable.Stack
case class Tower(name: String, disks: Stack[Int])
case class TohState(src: String, tgt: String, tmp: String)
case class TohStep(move: String, before: TohState, after: TohState)
object LazyToh {
val srcName = "SRC"

Install Oracle Java 8

Ubuntu
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
OSX
@sarveshseri
sarveshseri / sbt_help.md
Last active August 26, 2016 13:19
Hey sbt! Who are you?

Our new project

lets say we want to start a new scala project.

cd ~/Works
mkdir ScalaProject

So... the base directory for our project is ~/Work/ScalaProject.

The sbt convention for sources

Now, sbt will follow convention to try to find the following automatically,

@sarveshseri
sarveshseri / Main.scala
Created September 2, 2016 14:48
Medium :: Sbt :: The Simple Build Tool
object Main {
def main(args: Array[String]): Unit = {
println("---------")
println("Hi,")
println("I am Sbt and I am simple. :D")
println("---------")
}
}

First of all, lets understand few date-time standard definitions.

ISO Time String

The standard that we are talking about is formally named ISO 8601:1988 but is popularly also called ISO 8601

ISO 8601 also has support for

  • years before 0 AD or after 9999
  • Week based dates
  • Ordinal dates
@sarveshseri
sarveshseri / credentials
Last active September 7, 2019 20:38
how to use sbt with custom repositories
realm=my maven repo
host=my-maven-repo-host.com
user=xxxx
password=yyyy
@sarveshseri
sarveshseri / mongo_dump_restore.md
Last active September 8, 2019 23:31
Mongo Related Things
mongodump \ 
--host mongo_host \
--username username \
--password password\
--authenticationDatabase auth_db_name \
--db db_name \
--out dump_path