Sequim = squim
Snoqualmie = Snow-QUAL-me
Hoquiam = HOE-quim
Skokomish
Skokomish
Sammamish
Nisqualie
Tukwila
Puyallup
this is where the shit hits the fan, where the pedal hits the metal and where the rubber hits the road.
Sunday, May 24, 2015
Friday, February 20, 2015
bosh cpi + cf
bosh --> cloud provider interface --> cloud (aws, cloudstack, openstack, vsphere, google cloud, etc)
module bosh
class Cloud
methods:
def initialize(options)
def current_vm_id
def create_stemcell(image_path, cloud_properties)
def delete_stemcell(stemcell_id)
def create_vm(agent_id, stemcell_id, resource_pool,
def delete_vm(vm_id)
def has_vm?(vm_id)
def has_disk?(disk_id)
def reboot_vm(vm_id)
def set_vm_metadata(vm, metadata)
def configure_networks(vm_id, networks)
def create_disk(size, cloud_properties, vm_locality = nil)
def delete_disk(disk_id)
def attach_disk(vm_id, disk_id)
def snapshot_disk(disk_id, metadata={})
def delete_snapshot(snapshot_id)
def detach_disk(vm_id, disk_id)
def get_disks(vm_id)
def not_implemented(method)
fog.io:
fog: JSON/XML from iaaS provider --> fields of an object
release:
def initialize(options)
def start
def apply_spec_json
def apply_spec
def connect_to_agent
def compile
def find_by_name(enum, name)
def jobs_to_compile(name, manifest)
def apply_spec_job(job, job_path)
def cleanup
def prep_spec(deployment)
def compile_packages(dir, manifest, packages)
def find_package(manifest, name)
def compile_package(dir, package, name)
def untar(file)
def apply
def update_bosh_spec
def add_default_properties(spec_properties, job_properties)
Thursday, February 19, 2015
Cloud Foundry
- old orchestration
pick vlan, compute, storage
vms (linked clone + puppet/chef/etc for infra specific changes) + necessary packages for the app
hand over to the app admin teams to deploy the app (deploy)
app vs service distinction
- new orchestration
deployment: pull the code from git (heroku, openshift, flynn, dokku)
: pull the code as tar.gz (called blob store in cf)
: compile the code locally (worker vms in cf) and copy the exec to the Paas
provisioning: (done by bosh)
set up containers (DEA, agent)
config networking
install/config OS services or libraries like apache, ruby gem (buildpacks in cf)
lifecycle mgmt:
start the app
monitor/repot
restart
stop/start cli
service: polyglot persistence
service broker (managed): register/add/delete mysql/oracle/redis/rabitmq/etc
user-managed (legacy)
CF ops manager (GUI); behind the screens (bosh)
Bosh: stemcell + release + config.yml/manifest
bosh cli (esxcli) --> bosh director (vcenter) --NATS--> tasks
manifest: cloud infrastructure + n/w infra + vm types + OS type
Stemcell + Release + Manifest (SRM)
Changing clouds:
change the template/stemcell + change manifest (SM)
scale up app:
change one line in the manifest (M)
update/rollback the app:
change the release (R)
pick vlan, compute, storage
vms (linked clone + puppet/chef/etc for infra specific changes) + necessary packages for the app
hand over to the app admin teams to deploy the app (deploy)
app vs service distinction
- new orchestration
deployment: pull the code from git (heroku, openshift, flynn, dokku)
: pull the code as tar.gz (called blob store in cf)
: compile the code locally (worker vms in cf) and copy the exec to the Paas
provisioning: (done by bosh)
set up containers (DEA, agent)
config networking
install/config OS services or libraries like apache, ruby gem (buildpacks in cf)
lifecycle mgmt:
start the app
monitor/repot
restart
stop/start cli
service: polyglot persistence
service broker (managed): register/add/delete mysql/oracle/redis/rabitmq/etc
user-managed (legacy)
CF ops manager (GUI); behind the screens (bosh)
Bosh: stemcell + release + config.yml/manifest
bosh cli (esxcli) --> bosh director (vcenter) --NATS--> tasks
manifest: cloud infrastructure + n/w infra + vm types + OS type
Stemcell + Release + Manifest (SRM)
Changing clouds:
change the template/stemcell + change manifest (SM)
scale up app:
change one line in the manifest (M)
update/rollback the app:
change the release (R)
Thursday, January 22, 2015
Java
http://learnxinyminutes.com/docs/java/
primitive data types:
wrapper
autoboxing and unboxing
cf: int vs Integer
Class:
class variables (static keyword)
instance variables ( ~static, no-static keyword)
class methods (static)
instance methods (~static)
constructors
class initialization block
instance initialization block
overloading:
both static and non-static can be overloaded.
you can over load public static void main(String[] args)
you can hide the main method in the subclass
param types; order of params; types of params
same return type:
public int foo() {}
public float foo {}
foo(); // which foo
most specific method overloaded
http://stackoverflow.com/questions/20313052/java-static-and-dynamic-binding-upcast-overloading-mixed-together
constructors:
no return type
not inherited (thats why super())
void Class() {}, different from the constr.
http://stackoverflow.com/questions/6801500/why-do-constructors-in-java-not-have-a-return-type
compiler automatically inserts super()
no constructor: compiler generates default constructor, which calls super().
error: Implicit super constructor xyzClass() is undefined for default constructor. Must define an explicit constructor
http://www.fredosaurus.com/notes-java/oop/constructors/constructor-super.html
http://stackoverflow.com/questions/1197634/java-error-implicit-super-constructor-is-undefined-for-default-constructor
constructor chaining:
private consructors: (workaround for static class ala c#)
to avoid creating a new instance
singleton instance
intialization block:
instance: { }
class: static { }
order: in the textual order
class int blk runs when class is loaded to JVM
instance int blk run when a new instance is created
constructors, intialization block:
super()
instance intialization block
constructor code
http://www.programcreek.com/2011/10/java-class-instance-initializers/
order: compiler inserts super(); then inserts instance intialization block; before the constructor code
anon constructors = intialization block
https://javafeel.wordpress.com/2012/05/03/anonymous-constructors/
the above link shows the importance of anonymous class
access modifiers: public, protected, default (isn't a keyword), private
public > protected > default > private
default = package private
instatiation:
= new
Class1 x = new Class1
shadowing:
same variables, lexical scope
this.x = x
instance.x = local x
upcasting:
allowed
Class1 extends Class2;
Class 2 x = new Class1
downcasting:
allowed if there's a possibilty to succeed at runtime
http://stackoverflow.com/questions/380813/downcasting-in-java
abstract, final:
abstract: no new, but can be extended/subclassed
final: new (can be instantiated), but can't be extended
interface (is an abstract class)
consonants: static final
abstract methods
a way for multiple inheritance
calling instance method vs. class method:
Class1 A = new Class1()
A.method() //instance method
Class1.Staticmethod //class method
Class1.x //class var
A.x //instance var
member:
member methods
member variable
member class
variable:
class v
instance v
local v (inside a method)
shadowing/hiding (no overriding)
http://www.xyzws.com/Javafaq/what-is-variable-hiding-and-shadowing/15
nested class:
static: nested static class
non-static: inner class
nested static class:
can't access outer class instance variables/methods.
inner class:
member class: inner class
method class: class within a method: local method
anonymous class
http://www.cis.upenn.edu/~matuszek/General/JavaSyntax/inner-classes.html
anonymous class:
an object, but not a class
non-static
no name
when only a single instance of the class is needed.
new keyword
class definition + object creation combined
accesses static final fields outside of the scope
one element array trick: MyType[] localVar = {initialValue};
localVar[0] = newValue; check the following
https://www.clear.rice.edu/comp310/JavaResources/anon_inner.html
http://stackoverflow.com/questions/3251018/java-anonymous-inner-class-using-a-local-variable
possible in the static context: static A a = new A(), check the following
http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class
anon class creation:
interface, class reference var, argument
interface: an instance of the class that implements that interface
class reference variable
if class, anon class is an object of the subclass
anon class with parameter:
no direct way
possible with intializer
http://stackoverflow.com/questions/5107158/how-to-pass-parameters-to-anonymous-class
inheritance: extends implements multiple interaces.
overriding (complements hiding):
just for non-static/instance methods
can't override (can't hide) a private method, but can use the same method in the derived class
http://stackoverflow.com/questions/2000137/overriding-private-methods-in-java
hiding:
static/class methods
class variables
instance variables
overriding vs hiding:
http://docs.oracle.com/javase/tutorial/java/IandI/override.html
super:
calling superclass method: super.method()
subclass constructors: super() or super(arg1), etc
super vs this:
this (anon class)
outerclass.this (instance of outerclass)
http://tomlee.co/2007/06/java-this-and-inneranonymous-classes/
http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
instantiation of inner class:
new outerClass.new innerClass() or
Outer outer = new Outer();
Outer.Inner = outer.new Inner();
http://www.programmerinterview.com/index.php/java-questions/java-inner-class-example/
http://stackoverflow.com/questions/12690128/how-to-instantiate-non-static-inner-class-within-a-static-method
instatiation of nested static class:
within the outer class:
from the outside: Outer.Nested instance = new Outer.Nested()
calling outerclass from innerclass:
outer.this.method()
http://stackoverflow.com/questions/2808501/calling-outer-class-function-from-inner-class
A
local class instatiation:
only from the insider the method
Class Outer {
public void printText() {
class Local {
}
Local local = new Local();
}
}
http://tutorials.jenkov.com/java/nested-classes.html
inner class from outside: java puzzle 9
http://www.javapuzzlers.com/java-puzzlers-sampler.pdf
http://stackoverflow.com/questions/3383460/odd-situation-for-cannot-reference-this-before-supertype-constructor-has-been-c
public class Outer {
class Inner1 extends Outer {
Inner1() { super (); }
}
class Inner2 extendes Inner1 {
Inner2() { Outer.this.super();}
}
}
extending outer class with a nested inner class:
http://stackoverflow.com/questions/2000137/overriding-private-methods-in-java
What are the differences between method overloading and method overriding?
http://beginnersbook.com/2013/04/runtime-compile-time-polymorphism/
Liskov substitution principle:
Square is a rectangle
http://stackoverflow.com/questions/56860/what-is-the-liskov-substitution-principle
example on restriction: Mauricio Linhares' answer
http://stackoverflow.com/questions/6851612/java-access-modifiers-and-overriding-methods
calling static methods from instance:
allowed, but warnings
you can make the instance null, yet static calls produce results
http://stackoverflow.com/questions/610458/why-isnt-calling-a-static-method-by-way-of-an-instance-an-error-for-the-java-co
constants
static final
interface
static import (newer): java.lang.Math.PI
fields:
you can hide
you can access super class fields: super.x
*you can access enclosing class fields: innerclass.super.x
abstract class:
at least one method is abstract
abstract a extends abstract b
interface
marker/tag interface = no fields, no methods: ex: Clonable
only consonants + signature
interface X extends interface1, interface2, interface3
(illegal) interface X implements interface1, interface2, interface3
http://codeinventions.blogspot.com/2014/07/can-interface-extend-multiple.html
interface vs abstract combo:
interface can't extend pure (100%) abstract
interface can extend other interfaces (note: extends, not implements)
abstract can extend interface
abstract can implement interface
http://stackoverflow.com/questions/197893/why-an-abstract-class-implementing-an-interface-can-miss-the-declaration-impleme
final:
static final constants
final method: neither overriden nor hidden
final variable can be hidden
static final variable can be hidden (used is a better word) too (puzzle 72, java puzzlers)
static (belong to class, not an instance)
no static methods in abstract class
an instance method can call static method (but compiler warns)
static methods can be hidden, but can't be overriden
static methods can't be overriden by instance methods (compile error)
static methods can't hide instance methods (compile error)
Superclass d = new subclass(); //d.field prints field from Superclass
static fields can be hidden with non-static and static fields with the same name
hiding fields:
'public static String' type field can be hidden with 'protect int' field in the subclass
narrowing visibility: public > protected > default > private
static > non-static
types don't matter
http://geekexplains.blogspot.com/2008/06/field-hiding-in-java-fields-are-only.html
private:
private members( methods or fields) can't be overriden or hidden
same method/member with the same signature can be defined in the subclass.
@annotations
predefined vs custom
type annotations (use, new in 1.8)
format annon type
predefined: @Deprecated, @Override, @SuppressWarnings
@Override, not required, helps to prevent errors
@SuppressWarnings({"unchecked", "deprecation")
@SafeVarargs: does not perform unsafe operations on its varrags param
meta-annotations: @Inherited (annotation), @Repeatable, @Target, @Documented, @Retention
common practices:
http://www.javapractices.com/home/HomeAction.do
primitive data types:
wrapper
autoboxing and unboxing
cf: int vs Integer
Class:
class variables (static keyword)
instance variables ( ~static, no-static keyword)
class methods (static)
instance methods (~static)
constructors
class initialization block
instance initialization block
overloading:
both static and non-static can be overloaded.
you can over load public static void main(String[] args)
you can hide the main method in the subclass
param types; order of params; types of params
same return type:
public int foo() {}
public float foo {}
foo(); // which foo
most specific method overloaded
http://stackoverflow.com/questions/20313052/java-static-and-dynamic-binding-upcast-overloading-mixed-together
constructors:
no return type
not inherited (thats why super())
void Class() {}, different from the constr.
http://stackoverflow.com/questions/6801500/why-do-constructors-in-java-not-have-a-return-type
compiler automatically inserts super()
no constructor: compiler generates default constructor, which calls super().
error: Implicit super constructor xyzClass() is undefined for default constructor. Must define an explicit constructor
http://www.fredosaurus.com/notes-java/oop/constructors/constructor-super.html
http://stackoverflow.com/questions/1197634/java-error-implicit-super-constructor-is-undefined-for-default-constructor
constructor chaining:
private consructors: (workaround for static class ala c#)
to avoid creating a new instance
singleton instance
intialization block:
instance: { }
class: static { }
order: in the textual order
class int blk runs when class is loaded to JVM
instance int blk run when a new instance is created
constructors, intialization block:
super()
instance intialization block
constructor code
http://www.programcreek.com/2011/10/java-class-instance-initializers/
order: compiler inserts super(); then inserts instance intialization block; before the constructor code
anon constructors = intialization block
https://javafeel.wordpress.com/2012/05/03/anonymous-constructors/
the above link shows the importance of anonymous class
access modifiers: public, protected, default (isn't a keyword), private
public > protected > default > private
default = package private
instatiation:
Class1 x = new Class1
shadowing:
same variables, lexical scope
this.x = x
instance.x = local x
upcasting:
allowed
Class1 extends Class2;
Class 2 x = new Class1
downcasting:
allowed if there's a possibilty to succeed at runtime
http://stackoverflow.com/questions/380813/downcasting-in-java
abstract, final:
abstract: no new, but can be extended/subclassed
final: new (can be instantiated), but can't be extended
interface (is an abstract class)
consonants: static final
abstract methods
a way for multiple inheritance
calling instance method vs. class method:
Class1 A = new Class1()
A.method() //instance method
Class1.Staticmethod //class method
Class1.x //class var
A.x //instance var
member:
member methods
member variable
member class
variable:
class v
instance v
local v (inside a method)
shadowing/hiding (no overriding)
http://www.xyzws.com/Javafaq/what-is-variable-hiding-and-shadowing/15
nested class:
static: nested static class
non-static: inner class
nested static class:
can't access outer class instance variables/methods.
inner class:
member class: inner class
method class: class within a method: local method
anonymous class
http://www.cis.upenn.edu/~matuszek/General/JavaSyntax/inner-classes.html
anonymous class:
an object, but not a class
non-static
no name
when only a single instance of the class is needed.
new keyword
class definition + object creation combined
accesses static final fields outside of the scope
one element array trick: MyType[] localVar = {initialValue};
localVar[0] = newValue; check the following
https://www.clear.rice.edu/comp310/JavaResources/anon_inner.html
http://stackoverflow.com/questions/3251018/java-anonymous-inner-class-using-a-local-variable
possible in the static context: static A a = new A(), check the following
http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class
anon class creation:
interface, class reference var, argument
interface: an instance of the class that implements that interface
class reference variable
if class, anon class is an object of the subclass
anon class with parameter:
no direct way
possible with intializer
http://stackoverflow.com/questions/5107158/how-to-pass-parameters-to-anonymous-class
inheritance: extends
overriding (complements hiding):
just for non-static/instance methods
can't override (can't hide) a private method, but can use the same method in the derived class
http://stackoverflow.com/questions/2000137/overriding-private-methods-in-java
hiding:
static/class methods
class variables
instance variables
overriding vs hiding:
http://docs.oracle.com/javase/tutorial/java/IandI/override.html
super:
calling superclass method: super.method()
subclass constructors: super() or super(arg1), etc
super vs this:
this (anon class)
outerclass.this (instance of outerclass)
ClassName.this
is the n-th lexically enclosing instance of this
http://tomlee.co/2007/06/java-this-and-inneranonymous-classes/
http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
instantiation of inner class:
new outerClass.new innerClass() or
Outer outer = new Outer();
Outer.Inner = outer.new Inner();
http://www.programmerinterview.com/index.php/java-questions/java-inner-class-example/
http://stackoverflow.com/questions/12690128/how-to-instantiate-non-static-inner-class-within-a-static-method
instatiation of nested static class:
within the outer class:
from the outside: Outer.Nested instance = new Outer.Nested()
calling outerclass from innerclass:
outer.this.method()
http://stackoverflow.com/questions/2808501/calling-outer-class-function-from-inner-class
A
static
inner class like your fragment cannot access the outer class instance OuterClass.this
local class instatiation:
only from the insider the method
Class Outer {
public void printText() {
class Local {
}
Local local = new Local();
}
}
http://tutorials.jenkov.com/java/nested-classes.html
inner class from outside: java puzzle 9
http://www.javapuzzlers.com/java-puzzlers-sampler.pdf
http://stackoverflow.com/questions/3383460/odd-situation-for-cannot-reference-this-before-supertype-constructor-has-been-c
public class Outer {
class Inner1 extends Outer {
Inner1() { super (); }
}
class Inner2 extendes Inner1 {
Inner2() { Outer.this.super();}
}
}
extending outer class with a nested inner class:
http://stackoverflow.com/questions/2000137/overriding-private-methods-in-java
What are the differences between method overloading and method overriding?
Overloaded Method | Overridden Method | |
---|---|---|
Arguments | Must change | Must not change |
Return type | Can change | Can’t change except for covariant returns |
Exceptions | Can change | Can reduce or eliminate. Must not throw new or broader checked exceptions |
Access | Can change | Must not make more restrictive (can be less restrictive) |
Invocation | Reference type determines which overloaded version is selected. Happens at compile time. | Object type determines which method is selected. Happens at runtime. |
http://beginnersbook.com/2013/04/runtime-compile-time-polymorphism/
Liskov substitution principle:
Square is a rectangle
http://stackoverflow.com/questions/56860/what-is-the-liskov-substitution-principle
example on restriction: Mauricio Linhares' answer
http://stackoverflow.com/questions/6851612/java-access-modifiers-and-overriding-methods
calling static methods from instance:
allowed, but warnings
you can make the instance null, yet static calls produce results
http://stackoverflow.com/questions/610458/why-isnt-calling-a-static-method-by-way-of-an-instance-an-error-for-the-java-co
constants
static final
interface
static import (newer): java.lang.Math.PI
fields:
you can hide
you can access super class fields: super.x
*you can access enclosing class fields: innerclass.super.x
abstract class:
at least one method is abstract
abstract a extends abstract b
interface
marker/tag interface = no fields, no methods: ex: Clonable
only consonants + signature
interface X extends interface1, interface2, interface3
(illegal) interface X implements interface1, interface2, interface3
http://codeinventions.blogspot.com/2014/07/can-interface-extend-multiple.html
interface vs abstract combo:
interface can't extend pure (100%) abstract
interface can extend other interfaces (note: extends, not implements)
abstract can extend interface
abstract can implement interface
http://stackoverflow.com/questions/197893/why-an-abstract-class-implementing-an-interface-can-miss-the-declaration-impleme
final:
static final constants
final method: neither overriden nor hidden
final variable can be hidden
static final variable can be hidden (used is a better word) too (puzzle 72, java puzzlers)
static (belong to class, not an instance)
no static methods in abstract class
an instance method can call static method (but compiler warns)
static methods can be hidden, but can't be overriden
static methods can't be overriden by instance methods (compile error)
static methods can't hide instance methods (compile error)
Superclass d = new subclass(); //d.field prints field from Superclass
static fields can be hidden with non-static and static fields with the same name
hiding fields:
'public static String' type field can be hidden with 'protect int' field in the subclass
narrowing visibility: public > protected > default > private
static > non-static
types don't matter
http://geekexplains.blogspot.com/2008/06/field-hiding-in-java-fields-are-only.html
private:
private members( methods or fields) can't be overriden or hidden
same method/member with the same signature can be defined in the subclass.
@annotations
predefined vs custom
type annotations (use, new in 1.8)
format annon type
predefined: @Deprecated, @Override, @SuppressWarnings
@Override, not required, helps to prevent errors
@SuppressWarnings({"unchecked", "deprecation")
@SafeVarargs: does not perform unsafe operations on its varrags param
meta-annotations: @Inherited (annotation), @Repeatable, @Target, @Documented, @Retention
common practices:
http://www.javapractices.com/home/HomeAction.do
Tuesday, January 6, 2015
Monday, September 8, 2014
Pointers
1. Everything you need to know about points by bored zo
2. A tutorial on pointers and arrays by Ted Jensen
3. Introduction to pointers by fringer
4. Function pointer tutorials
5. Pointers by Gribble lab
6. Pointers binky
7. Steve Summit's notes and faqs
8. lvalues, rvalues and pointers Dmitry Votsokov (every lvalue is rvalue, rvalue can't be writable)
9. Richard Reese's book: Understanding and Using C Pointers
2. A tutorial on pointers and arrays by Ted Jensen
3. Introduction to pointers by fringer
4. Function pointer tutorials
5. Pointers by Gribble lab
6. Pointers binky
7. Steve Summit's notes and faqs
8. lvalues, rvalues and pointers Dmitry Votsokov (every lvalue is rvalue, rvalue can't be writable)
9. Richard Reese's book: Understanding and Using C Pointers
Wednesday, July 16, 2014
Subscribe to:
Posts (Atom)