This file contains 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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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
package com.yammer.dropwizard.json; | |
import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |
import com.fasterxml.jackson.databind.cfg.MapperConfig; | |
import com.fasterxml.jackson.databind.introspect.AnnotatedField; | |
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; | |
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; | |
/** | |
* A {@link PropertyNamingStrategy} implementation which, if the declaring class of a property is |
This file contains 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
Running commands on several remote hosts using ssh and xargs | |
There are a few different ways to run commands on groups or clusters of remote nodes, depending upon how complex the command. | |
Assuming your machines are named "node01" - "node22" : | |
# Run a command in parallel on all remote nodes | |
# results come back in random order as they are received. | |
pdsh -w "node[01-22]" df |
This file contains 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
AliasesExist HEAD /_alias/{name} | |
AliasesExist HEAD /{index}/_alias/{name} | |
Analyze GET /_analyze | |
Analyze GET /{index}/_analyze | |
Analyze POST /_analyze | |
Analyze POST /{index}/_analyze | |
Bulk POST /_bulk | |
Bulk POST /{index}/_bulk | |
Bulk POST /{index}/{type}/_bulk | |
Bulk PUT /_bulk |
This file contains 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
// Skip compiling and running tests | |
mvn package -Dmaven.test.skip=true | |
// Skip running tests in the Jar but compile (and include) them in the jar | |
mvn package -DskipTests | |
// | |
mvn package |
This file contains 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
AssistedInject allows you to dynamically configure Factory for class instead of coding it by yourself. This is often useful when you have an object that has a dependencies that should be injected and some parameters that must be specified during creation of object. | |
Example from docummentaiton is a RealPayment | |
public class RealPayment implements Payment { | |
@Inject | |
public RealPayment( | |
CreditService creditService, | |
AuthService authService, | |
@Assisted Date startDate, |
This file contains 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
// CheckedProvider is an interface, which is a part of extension guice-throwingproviders. | |
public interface CheckedProvider<T> { | |
T get() throws Exception; | |
} | |
// Injection | |
@Inject | |
private ExcelCheckedProvider<FlightSupplier> excelCheckedProvider; | |
// Binding |
This file contains 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
bindConstant(). | |
annotatedWith(Names.named("maxResults")). | |
to(10); | |
@Inject | |
public void setMaxResults(@Named("maxResults")int maxResults) { | |
this.maxResults = maxResults; | |
} |
This file contains 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 class DelivererBuilder { | |
private final MailServerFinder finder; | |
private Newsletter newsletter; | |
private String mailServerUrl; | |
private int port; | |
@Inject | |
public DelivererBuilder(MailServerFinder finder) { | |
this.finder = finder; | |
} |
This file contains 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 Deliverer buildDeliverer() { | |
try { | |
return new Deliverer(letter, mailServerUrl, port); | |
} finally { | |
letter = null; | |
mailServerUrl = null; | |
port = -1; | |
} | |
} |
NewerOlder