Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4 from fpj/master
Browse files Browse the repository at this point in the history
Major bug in the config constructor
  • Loading branch information
dgomezferro committed Apr 13, 2012
2 parents 2582a6f + d57ea37 commit b2f9cf1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/yahoo/omid/tso/TSOServer.java
Expand Up @@ -115,7 +115,7 @@ public void run() {
// TODO: make it singleton
//TimestampOracle timestampOracle = new TimestampOracle();
// The wrapper for the shared state of TSO
state = BookKeeperStateBuilder.getState();
state = BookKeeperStateBuilder.getState(this.config);

if(state == null){
LOG.error("Couldn't build state");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/yahoo/omid/tso/TSOServerConfig.java
Expand Up @@ -59,10 +59,10 @@ static public TSOServerConfig configFactory(int port, int batch, boolean recover
TSOServerConfig(int port, int batch, boolean recoveryEnabled, int ensemble, int quorum, String zkServers){
this.port = port;
this.batch = batch;
this.recoveryEnabled = Boolean.parseBoolean(System.getProperty("RECOVERABLE", "false"));
this.zkServers = System.getProperty("ZKSERVERS");
this.ensemble = Integer.parseInt(System.getProperty("ENSEMBLE", "3"));
this.quorum = Integer.parseInt(System.getProperty("QUORUM", "2"));
this.recoveryEnabled = recoveryEnabled;
this.zkServers = zkServers;
this.ensemble = ensemble;
this.quorum = quorum;
}

public int getPort(){
Expand Down
Expand Up @@ -44,6 +44,8 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.yahoo.omid.tso.TSOServerConfig;
import com.yahoo.omid.tso.TSOState;
import com.yahoo.omid.tso.TimestampOracle;
import com.yahoo.omid.tso.persistence.BookKeeperStateLogger.LedgerIdCreateCallback;
Expand Down Expand Up @@ -72,13 +74,13 @@ public class BookKeeperStateBuilder extends StateBuilder {
*/
private static final long BKREADBATCHSIZE = 50;

public static TSOState getState(){
public static TSOState getState(TSOServerConfig config){
TSOState returnValue;
if(System.getProperty("ZKSERVERS") == null){
if(config.getZkServers() == null){
LOG.warn("Logger is disabled");
returnValue = new TSOState(new TimestampOracle());
} else {
BookKeeperStateBuilder builder = new BookKeeperStateBuilder();
BookKeeperStateBuilder builder = new BookKeeperStateBuilder(config);

try{
returnValue = builder.buildState();
Expand All @@ -97,9 +99,11 @@ public static TSOState getState(){
ZooKeeper zk;
LoggerProtocol lp;
boolean enabled;
TSOServerConfig config;

BookKeeperStateBuilder() {
this.timestampOracle = new TimestampOracle();
BookKeeperStateBuilder(TSOServerConfig config) {
this.timestampOracle = new TimestampOracle();
this.config = config;
}

/**
Expand Down Expand Up @@ -225,7 +229,7 @@ public TSOState buildState()
try{
CountDownLatch latch = new CountDownLatch(1);

this.zk = new ZooKeeper(System.getProperty("ZKSERVERS"),
this.zk = new ZooKeeper(config.getZkServers(),
Integer.parseInt(System.getProperty("SESSIONTIMEOUT", Integer.toString(10000))),
new LoggerWatcher(latch));

Expand Down

0 comments on commit b2f9cf1

Please sign in to comment.