Skip to content
Snippets Groups Projects
Commit 12b14fbd authored by Michael Eischer's avatar Michael Eischer
Browse files

Speedup replica initialization

This defers the creation of request paths until a
client is actually instantiated. Previously this initialization
happened when REFITConfig loaded the client class, which
slows down the configuration check.
parent 57a92b14
No related branches found
No related tags found
No related merge requests found
......@@ -9,18 +9,21 @@ import refit.util.REFITTime;
public class REZKTestClientExists extends REZKTestClient {
private static final String[] prePaths = new String[2 * REFITConfig.NR_OF_NODES];
static {
for (int i = 0; i < prePaths.length; i++) {
prePaths[i] = String.format("%s%05d", "/node", i);
}
}
private String[] paths;
private boolean[] isValidPath;
private int counter = 0;
public REZKTestClientExists(REFITClientLibrary service) {
super(service);
synchronized (prePaths) {
if (prePaths[0] == null) {
for (int i = 0; i < prePaths.length; i++) {
prePaths[i] = String.format("%s%05d", "/node", i);
}
}
}
paths = new String[REFITConfig.NR_OF_NODES];
isValidPath = new boolean[paths.length];
// ensure reproducibility
......
......@@ -12,17 +12,20 @@ import refit.util.REFITTime;
public class REZKTestClientReadWrite extends REZKTestClient {
private static final String[] paths = new String[REFITConfig.NR_OF_NODES];
static {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
private int counter = 0;
private Random rand;
public REZKTestClientReadWrite(REFITClientLibrary service) {
super(service);
synchronized (paths) {
if (paths[0] == null) {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
}
rand = new Random(service.getNodeID());
}
......
......@@ -11,18 +11,21 @@ import refit.util.REFITTime;
public class REZKTestClientReadWriteActive extends REZKTestClient {
private static final String[] paths = new String[REFITConfig.NR_OF_NODES];
static {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
private static AtomicLong nextObj = new AtomicLong();
private int counter = 0;
private Random rand;
public REZKTestClientReadWriteActive(REFITClientLibrary service) {
super(service);
synchronized (paths) {
if (paths[0] == null) {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
}
rand = new Random(service.getNodeID());
}
......
......@@ -10,16 +10,19 @@ import refit.util.REFITTime;
public class REZKTestClientReadWriteConflict extends REZKTestClient {
private static final String[] paths = new String[REFITConfig.ACTIVE_NODES];
static {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
private Random rand;
public REZKTestClientReadWriteConflict(REFITClientLibrary service) {
super(service);
synchronized (paths) {
if (paths[0] == null) {
for (int i = 0; i < paths.length; i++) {
paths[i] = String.format("%s%05d", "/node", i);
}
}
}
rand = new Random(service.getNodeID());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment