There are many confusion about zookeeper,what zookeeper is ?.
What is the role of zookeeper .What zookeeper does.
In Simple term,Zookeeper ensure people or node which are agreed to work together ,should work together.
Read Preference Mode
|
Description
|
In most situations, operations read from secondary members but if no secondary members are available, operations read from the primary.
| |
Operations read from member of the replica set with the least network latency, irrespective of the member’s type.
|
// function somewhere in father-controller.js var makePromiseWithSon = function() { // This service's function returns a promise, but we'll deal with that shortly SonService.getWeather() // then() called when son gets back .then(function(data) { // promise fulfilled if (data.forecast==='good') { prepareFishingTrip(); } else { prepareSundayRoastDinner(); } }, function(error) { // promise rejected, could log the error with: console.log('error', error); prepareSundayRoastDinner(); }); };
app.factory('SonService', function ($http, $q) { return { getWeather: function() { // the $http API is based on the deferred/promise APIs exposed by the $q service // so it returns a promise for us by default return $http.get('http://fishing-weather-api.com/sunday/afternoon') .then(function(response) { if (typeof response.data === 'object') { return response.data; } else { // invalid response return $q.reject(response.data); } }, function(response) { // something went wrong return $q.reject(response.data); }); } }; });
public class Singleton {
private Prototype prototype;
public Singleton(Prototype prototype) {
this.prototype = prototype;
}
public void doSomething() {
prototype.foo();
}
public void doSomethingElse() {
prototype.bar();
}
}
public abstract class Singleton {
protected abstract Prototype createPrototype();
public void doSomething() {
createPrototype().foo();
}
public void doSomethingElse() {
createPrototype().bar();
}
}
<bean id="prototype" class="ch.frankel.blog.Prototype" scope="prototype" />
<bean id="singleton" class="sample.MySingleton">
<lookup-method name="createPrototype" bean="prototype" />
</bean>