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
try { | |
long startTime = System.currentTimeMillis(); | |
int port = 8000; | |
InetAddress server = InetAddress.getByAddress("8.8.8.8".getBytes()); | |
DatagramSocket socket = new DatagramSocket(port); | |
byte[] buf = new byte[1024]; | |
DatagramPacket ping = new DatagramPacket(buf, buf.length, server, port); |
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
try { | |
int port = 8000; | |
InetAddress address = InetAddress.getByName("8.8.8.8"); | |
DatagramSocket socket = new DatagramSocket(); | |
socket.setSoTimeout(2000); | |
socket.connect(address, port); | |
for(int i = 0; i < NUM_TRIALS; i++){ | |
String str = "PING " + i + " \n"; | |
byte[] buf = new byte[1024]; | |
buf = str.getBytes(); |
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
public static void main(String[] args) { | |
MyScanner in = new MyScanner(); | |
} | |
// -----------MyScanner class for faster input---------- | |
public static class MyScanner { | |
BufferedReader br; | |
StringTokenizer st; | |
public MyScanner() { |
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
def start_instance_elections(instance_ids): | |
session = boto3.session.Session(profile_name='default') | |
ec2_resource = session.resource('ec2')#high level resource level | |
key = paramiko.RSAKey.from_private_key_file('/home/edward/workspace/waka/mykeypair.pem') | |
Port = 22 | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
print('starting election on instances') |
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
54.165.12.246 | |
54.173.172.71 | |
54.175.78.8 | |
54.165.227.128 |
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
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar | |
network interface: name:eth0 (eth0) | |
network interface: name:lo (lo) | |
start | |
Gossiping: [] | |
{"address":"172.31.31.206","heartbeat":1458921462576,"generation_time":1458921455000,"status":"NORMAL"} | |
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found. | |
at org.json.JSONObject.get(JSONObject.java:471) | |
at org.json.JSONObject.getString(JSONObject.java:717) | |
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:46) |
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
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar | |
start | |
Gossiping: [] | |
{"address":"172.31.31.206","heartbeat":1458921136784,"generation_time":1458921132782,"status":"NORMAL"} | |
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found. | |
at org.json.JSONObject.get(JSONObject.java:471) | |
at org.json.JSONObject.getString(JSONObject.java:717) | |
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:46) | |
at com.tbdcomputing.network.Flock$2.onNodeDiscovered(Flock.java:62) | |
at com.tbdcomputing.network.discovery.NetworkDiscoveryReceiver.run(NetworkDiscoveryReceiver.java:39) |
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
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar | |
start | |
Gossiping: [] | |
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found. | |
at org.json.JSONObject.get(JSONObject.java:471) | |
at org.json.JSONObject.getString(JSONObject.java:717) | |
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:45) | |
at com.tbdcomputing.network.Flock$2.onNodeDiscovered(Flock.java:62) | |
at com.tbdcomputing.network.discovery.NetworkDiscoveryReceiver.run(NetworkDiscoveryReceiver.java:39) | |
at com.tbdcomputing.network.Flock$3.run(Flock.java:144) |
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 xml.etree.ElementTree as ET | |
from math import sqrt | |
import json | |
import numpy as np | |
import pandas as pd | |
from pandas import Series, DataFrame | |
import os | |
import io | |
os.chdir('/home/edward/workspace/school/context_slices') | |
os.getcwd() |
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
public static int[] diff(Node head, int height){ | |
if(head.left == null && head.right == null){ | |
int[] base = new int[2]; | |
base[0] = 0; | |
base[1] = 0; | |
} | |
int[] left = new int[2]; | |
left[0] = Integer.MAX_VALUE; |