use of edu.umass.cs.gnsclient.client.GNSClient in project GNS by MobilityFirst.
the class SequentialCreateFieldTimeout method setUpBeforeClass.
/**
*
* @throws Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
client = new GNSClientCommands();
// Make all the reads be coordinated
client.setForceCoordinatedReads(true);
// arun: connectivity check embedded in GNSClient constructor
boolean connected = client instanceof GNSClient;
if (connected) {
System.out.println("Client created and connected to server.");
}
//
int tries = 5;
boolean accountCreated = false;
do {
try {
System.out.println("Creating account guid: " + (tries - 1) + " attempt remaining.");
masterGuid = GuidUtils.lookupOrCreateAccountGuid(client, accountAlias, PASSWORD, true);
accountCreated = true;
} catch (Exception e) {
ThreadUtils.sleep((5 - tries) * 5000);
}
} while (!accountCreated && --tries > 0);
if (accountCreated == false) {
fail("Failure setting up account guid; aborting all tests.");
}
}
use of edu.umass.cs.gnsclient.client.GNSClient in project GNS by MobilityFirst.
the class ServerIntegrationTest method setUpBeforeClassOld.
/**
* @throws FileNotFoundException
* @throws IOException
* @throws InterruptedException
*/
@Deprecated
public static void setUpBeforeClassOld() throws FileNotFoundException, IOException, InterruptedException {
/* The waitTillAllServersReady parameter is not needed for
* single-machine tests as we check the logs explicitly below. It is
* still useful for distributed tests as there is no intentionally
* support in gigapaxos' async client to detect if all servrs are up. */
String waitString = System.getProperty("waitTillAllServersReady");
if (waitString != null) {
WAIT_TILL_ALL_SERVERS_READY = Integer.parseInt(waitString);
}
// get pattern for log files
Properties logProps = new Properties();
logProps.load(new FileInputStream(System.getProperty(DefaultProps.LOGGING_PROPERTIES.key)));
String logFiles = logProps.getProperty("java.util.logging.FileHandler.pattern");
if (logFiles != null) {
logFiles = logFiles.replaceAll("%.*", "").trim() + "*";
}
new File(logFiles.replaceFirst("/[^/]*$", "")).mkdirs();
if (logFiles != null) {
System.out.print("Deleting log files " + logFiles);
RunCommand.command("rm -f " + logFiles, ".", false);
System.out.print(" ...done" + logFiles);
}
// start server
if (System.getProperty("startServer") != null && System.getProperty("startServer").equals("true")) {
// clear explicitly if gigapaxos
if (useGPScript()) {
// forceclear
String forceClearCmd = System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + getGigaPaxosOptions() + " forceclear all";
System.out.println(forceClearCmd);
RunCommand.command(forceClearCmd, ".");
/* We need to do this to limit the number of files used by mongo.
* Otherwise failed runs quickly lead to more failed runs because
* index files created in previous runs are not removed.
*/
dropAllDatabases();
options = getGigaPaxosOptions() + " restart all";
} else {
options = SCRIPTS_OPTIONS;
}
String startServerCmd = System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + options;
System.out.println(startServerCmd);
// servers are being started here
if (singleJVM()) {
startServersSingleJVM();
} else {
ArrayList<String> output = RunCommand.command(startServerCmd, ".");
if (output != null) {
for (String line : output) {
System.out.println(line);
}
} else {
failWithStackTrace("Server command failure: ; aborting all tests.");
}
}
}
int numServers = PaxosConfig.getActives().size() + ReconfigurationConfig.getReconfigurators().size();
ArrayList<String> output;
int numServersUp = 0;
// a little sleep ensures that there is time for at least one log file to get created
Thread.sleep(500);
if (!singleJVM()) {
do {
output = RunCommand.command("cat " + logFiles + " | grep -a \"server ready\" | wc -l ", ".", false);
String temp = output.get(0);
temp = temp.replaceAll("\\s", "");
try {
numServersUp = Integer.parseInt(temp);
} catch (NumberFormatException e) {
// can happen if no files have yet gotten created
System.out.println(e);
}
System.out.println(Integer.toString(numServersUp) + " out of " + Integer.toString(numServers) + " servers are ready.");
Thread.sleep(1000);
} while (numServersUp < numServers);
}
System.out.println("Starting client");
int numRetries = 2;
boolean forceCoordinated = true;
clientCommands = (GNSClientCommands) new GNSClientCommands().setNumRetriesUponTimeout(numRetries).setForceCoordinatedReads(forceCoordinated);
client = new GNSClient().setNumRetriesUponTimeout(numRetries).setForceCoordinatedReads(forceCoordinated).setForcedTimeout(8000);
System.out.println("Client created and connected to server.");
//
int tries = 5;
boolean accountCreated = false;
Thread.sleep(WAIT_TILL_ALL_SERVERS_READY);
do {
try {
System.out.println("Creating account guid: " + (tries - 1) + " attempt remaining.");
String createdGUID = client.execute(GNSCommand.createAccount(accountAlias)).getResultString();
Assert.assertEquals(createdGUID, GuidUtils.getGUIDKeys(accountAlias).guid);
// older code; okay to leave it hanging or to remove
masterGuid = GuidUtils.lookupOrCreateAccountGuid(clientCommands, accountAlias, PASSWORD, true);
accountCreated = true;
} catch (Exception e) {
e.printStackTrace();
ThreadUtils.sleep((5 - tries) * 4000);
}
} while (!accountCreated && --tries > 0);
if (accountCreated == false) {
failWithStackTrace("Failure setting up account guid; aborting all tests.");
}
}
use of edu.umass.cs.gnsclient.client.GNSClient in project GNS by MobilityFirst.
the class SecureCommandTestStandalone method test_01_SecureCreateClient.
/**
*
*/
@Test
public void test_01_SecureCreateClient() {
System.out.println(System.getProperty("gigapaxosConfig"));
System.out.println(System.getProperty("javax.net.ssl.keyStore"));
try {
client = new GNSClient();
client.setForceCoordinatedReads(true);
} catch (IOException e) {
Utils.failWithStackTrace("Exception creating client: ", e);
}
}
use of edu.umass.cs.gnsclient.client.GNSClient in project GNS by MobilityFirst.
the class SecureCommandTest method test_01_SecureCreateClient.
/**
*
*/
@Test
public void test_01_SecureCreateClient() {
try {
client = new GNSClient();
client.setForceCoordinatedReads(true);
} catch (IOException e) {
Utils.failWithStackTrace("Exception creating client: ", e);
}
}
use of edu.umass.cs.gnsclient.client.GNSClient in project GNS by MobilityFirst.
the class ServerFailureTests method setUpBeforeClass.
/**
*
* @throws Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
String topDir = Paths.get(".").toAbsolutePath().normalize().toString();
//Set the running time (in seconds) for each round of throughput testing.
String inputRoundTime = System.getProperty("failureTest.roundTime");
if (inputRoundTime != null) {
TEST_TIME = Integer.parseInt(inputRoundTime) * 1000;
} else {
//Default to 10,000 ms
TEST_TIME = 10000;
}
//Parse gigapaxos.properties file for the active replica names
String gpPropPath = System.getProperty("gigapaxosConfig");
System.out.println("Using gigapaxos config: " + gpPropPath);
gpPropDir = topDir + "/" + gpPropPath;
File file = new File(gpPropDir);
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = reader.readLine();
while (line != null) {
if (line.startsWith("active.")) {
int idx = line.indexOf(".");
int idx2 = line.indexOf("=", idx);
String serverName = line.substring(idx + 1, idx2);
suite.serverNameArray.add(serverName);
}
line = reader.readLine();
}
reader.close();
numServers = suite.serverNameArray.size();
System.out.println("Active Replicas to be used: " + suite.serverNameArray.toString());
//Kill any running servers
Process startProcess = Runtime.getRuntime().exec("kill -s TERM `ps -ef | grep GNS.jar | grep -v grep | grep -v ServerIntegrationTest | grep -v \"context\" | awk '{print $2}'`");
InputStream serverLauncherOutput = startProcess.getInputStream();
BufferedReader output = new BufferedReader(new InputStreamReader(serverLauncherOutput));
line = output.readLine();
while (startProcess.isAlive() && (line != null)) {
System.out.println(line);
line = output.readLine();
}
startProcess.waitFor();
//Kill any saved state
execString = topDir + "/bin/gpServer.sh -DgigapaxosConfig=" + gpPropDir + " ";
System.out.println("Running " + execString + "forceclear all");
startProcess = Runtime.getRuntime().exec(execString + "forceclear all");
serverLauncherOutput = startProcess.getInputStream();
output = new BufferedReader(new InputStreamReader(serverLauncherOutput));
line = output.readLine();
while (startProcess.isAlive() && (line != null)) {
System.out.println(line);
line = output.readLine();
}
startProcess.waitFor();
//Start the servers
System.out.println("Running " + execString + "restart all");
startProcess = Runtime.getRuntime().exec(execString + "restart all");
serverLauncherOutput = startProcess.getInputStream();
output = new BufferedReader(new InputStreamReader(serverLauncherOutput));
line = output.readLine();
while (startProcess.isAlive() && (line != null)) {
System.out.println(line);
line = output.readLine();
}
startProcess.waitFor();
System.out.println("Servers started.");
Thread.sleep(5000);
System.out.println("Starting client");
client = new GNSClientCommands();
// Make all the reads be coordinated
client.setForceCoordinatedReads(true);
// arun: connectivity check embedded in GNSClient constructor
boolean connected = client instanceof GNSClient;
if (connected) {
System.out.println("Client created and connected to server.");
}
//
int tries = 5;
boolean accountCreated = false;
do {
try {
System.out.println("Creating account guid: " + (tries - 1) + " attempt remaining.");
masterGuid = GuidUtils.lookupOrCreateAccountGuid(client, accountAlias, PASSWORD, true);
accountCreated = true;
} catch (Exception e) {
ThreadUtils.sleep((5 - tries) * 5000);
}
} while (!accountCreated && --tries > 0);
if (accountCreated == false) {
fail("Failure setting up account guid; aborting all tests.");
}
//Begin emulating transport delays -- This was causing timeouts on everything so it's unused out for now.
if (EMULATING_DELAYS) {
JSONDelayEmulator.emulateDelays();
}
}
Aggregations