1. trait Speaker {
val name:String
val aliases:Set[String]
}
trait Organization{
val bu = "tmall"
val group = "alibaba"
}
object WangFuqiang extends Speaker with Organization{
val name = "王福强"
val aliases = Set("千任", "@囚千任")
val blog = “http://afoo.me”
}
架构模式与实践漫谈
Sunday, July 14, 13
66. “Trade A For A” Async
Anti-Pattern
Sunday, July 14, 13
67. A yelled ‘get it done’
B working...
A looking/waiting/
smoking...
Sunday, July 14, 13
68. Future<Double> rateQuoteFuture = executor.submit(new Callable<Double>() {
@Override
public Double call() throws Exception {
connection.getCurrentValue(USD);
}
});
Double rateQuote = rateQuoteFuture.get(5, TimeUnit.SECONDS);
// Nothing more to do, just wait and return
Sunday, July 14, 13
69. Future<Double> rateQuoteFuture = executor.submit(new Callable<Double>() {
@Override
public Double call() throws Exception {
connection.getCurrentValue(USD);
}
});
Double rateQuote = rateQuoteFuture.get(5, TimeUnit.SECONDS);
// Nothing more to do, just wait and return
Why don’t U do it in current thread?
Sunday, July 14, 13
88. trait PartialFunction[-A, +B] extends (A => B) { self =>
import PartialFunction._
/** Checks if a value is contained in the function's domain.
*
* @param x the value to test
* @return `'''true'''`, iff `x` is in the domain of this function,
`'''false'''` otherwise.
*/
def isDefinedAt(x: A): Boolean
...
}
trait Function1[@specialized(..) -T1, @specialized(..) +R] extends AnyRef { self =>
/** Apply the body of this function to the argument.
* @return the result of function application.
*/
def apply(v1: T1): R
http://www.infoq.com/cn/articles/function-switch-realize-better-continuous-implementations
Switch.reduce{
}
Sunday, July 14, 13
127. So When you deploy clusters of
• Search Service
• HSF/Dubbo Service
• Data Storage Service
• Caching Service(Tair, Redis, memcached...)
• Whatever that’s important or have higher priority, NO Share!
Sunday, July 14, 13