bool ReplicatedConfig::Init() { Endpoint endpoint; nodeID = Config::GetIntValue("paxos.nodeID", 0); numNodes = Config::GetListNum("paxos.endpoints"); if (numNodes == 0) { endpoint.Set("0.0.0.0:10000"); endpoints[0] = endpoint; nodeID = 0; } else { if (nodeID < 0 || nodeID >= numNodes) STOP_FAIL("Configuration error, " "check your paxos.nodeID and paxos.endpoints entry" ,0); for (unsigned i = 0; i < numNodes; i++) { endpoint.Set(Config::GetListValue("paxos.endpoints", i, NULL), true); endpoints[i] = endpoint; } } if (strcmp("replicated", Config::GetValue("mode", "")) == 0) InitRestartCounter(); return true; }
void InitContextTransport() { const char* str; Endpoint endpoint; // set my endpoint str = configFile.GetValue("endpoint", ""); if (str == NULL) STOP_FAIL(1, "Missing \"endpoint\" in config file!"); if (!endpoint.Set(str, true)) STOP_FAIL(1, "Bad endpoint format in config file!"); CONTEXT_TRANSPORT->Init(endpoint); }
int Client::Init(int nodec, const char* nodev[]) { GLOBAL_MUTEX_GUARD_DECLARE(); // sanity check on parameters if (nodec <= 0 || nodev == NULL) return SDBP_API_ERROR; // TODO: find out the optimal size of MAX_SERVER_NUM if (!IOProcessor::Init(MAX_IO_CONNECTION)) return SDBP_API_ERROR; IOProcessor::BlockSignals(IOPROCESSOR_BLOCK_INTERACTIVE); // set default timeouts masterTimeout.SetDelay(3 * PAXOSLEASE_MAX_LEASE_TIME); globalTimeout.SetDelay(SDBP_DEFAULT_TIMEOUT); connectivityStatus = SDBP_NOCONNECTION; timeoutStatus = SDBP_SUCCESS; result = new Result; controllerConnections = new ControllerConnection*[nodec]; for (int i = 0; i < nodec; i++) { Endpoint endpoint; endpoint.Set(nodev[i], true); controllerConnections[i] = new ControllerConnection(this, (uint64_t) i, endpoint); } numControllers = nodec; master = -1; masterTime = 0; commandID = 0; masterCommandID = 0; consistencyLevel = SDBP_CONSISTENCY_STRICT; highestSeenPaxosID = 0; isBatched = false; return SDBP_SUCCESS; }
int Client::Init(int nodec, const char* nodev[]) { // validate args if (nodec <= 0 || nodev == NULL) return KEYSPACE_API_ERROR; if (!IOProcessor::Init(nodec + 64, false)) return KEYSPACE_API_ERROR; masterTimeout.SetDelay(3 * MAX_LEASE_TIME); globalTimeout.SetDelay(KEYSPACE_DEFAULT_TIMEOUT); connectivityStatus = KEYSPACE_NOCONNECTION; timeoutStatus = KEYSPACE_SUCCESS; result = new Result; conns = new ClientConn*[nodec]; for (int i = 0; i < nodec; i++) { Endpoint endpoint; endpoint.Set(nodev[i], true); conns[i] = new ClientConn(*this, i, endpoint); } numConns = nodec; master = -1; masterTime = 0; cmdID = 1; masterCmdID = 1; masterQuery = false; distributeDirty = false; currentConn = 0; return KEYSPACE_SUCCESS; }