Skip to content

Instantly share code, notes, and snippets.

View anjanashankar9's full-sized avatar

Anjana Shankar anjanashankar9

View GitHub Profile
@anjanashankar9
anjanashankar9 / Output.txt
Created October 26, 2015 05:56
Interfaces in Java8
Default method in implementation class
[{
"subcat": [{
"prod_type": [{
"name": "Bouquets & Bunches",
"attr": ["Size_2165_fa", "Type-of-Flowers_2166_fa", "Colour-of-Flower_2168_fa", "Type-of-Base_2169_fa"]
}, {
"name": "Basket Arrangements",
"attr": ["Size_2170_fa", "Type-of-Flowers_2171_fa", "Type-of-Arrangement_2172_fa", "Colour-of-Flower_2173_fa"]
}],
"name": "Flowers"
@anjanashankar9
anjanashankar9 / static_initalizer.java
Created July 9, 2019 16:09
Java - Static Initializer
class StaticTest {
static int i;
static {
System.out.println("Static Initialization block is called");
i = 10;
}
StaticTest() {
System.out.println("Static Test Constructor is called");
@anjanashankar9
anjanashankar9 / op1.txt
Created July 9, 2019 16:10
output of static initialization
Static Initialization block is called
10
@anjanashankar9
anjanashankar9 / instance_initializer.java
Last active November 15, 2021 17:12
Instance Initialization
class InitializerTest {
int i;
{
System.out.println("Instance Initialization block is called");
i = 5;
}
InitializerTest() {
System.out.println("Initializer Test Default Constructor is called");
@anjanashankar9
anjanashankar9 / op2.txt
Last active November 15, 2021 17:13
output of instance initialization
Instance Initialization block is called
Initializer Test Default Constructor is called
5
Instance Initialization block is called
Initializer Test Parametrized Constructor is called
10
public static CuratorFramework createConnection(String zookeeperConnectionString) {
//First retry will wait for 1 second,
//the second will wait up to 2 seconds,
//the third will wait upto 4 seconds.
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(zookeeperConnectionString)
.retryPolicy(retryPolicy)
.namespace("session_service")
.canBeReadOnly(true)
public static void create(CuratorFramework client, String path) throws Exception {
client.create().forPath(path);
}
public static void setData(CuratorFramework client, String path, String data) throws Exception {
byte[] payload = data.getBytes();
client.setData()
.forPath(path, payload);
}
public static void delete(CuratorFramework client, String path) throws Exception {
client.delete()
.forPath(path);
}