use of java.net.UnknownHostException in project SmartCity-Market by TechnionYP5777.
the class ClientRequestHandlerTest method ClientRequestHandlerUnknownHostTest.
@Test
public void ClientRequestHandlerUnknownHostTest() {
try {
ClientRequestHandler clientRequestHandler = new ClientRequestHandler();
clientRequestHandler.createSocket(portTest, SERVER_UKNOWN_HOST_NAME, TIMEOUT);
clientRequestHandler.finishRequest();
} catch (UnknownHostException e) {
/* success */
} catch (RuntimeException e) {
fail();
}
}
use of java.net.UnknownHostException in project SmartCity-Market by TechnionYP5777.
the class ThreadPooledServerTest method ServerWorkerRunnableHelloWorldIPTest.
@Test
public void ServerWorkerRunnableHelloWorldIPTest() {
ProcessRequestTester processRequestTester = new ProcessRequestTester();
ThreadPooledServer server = null;
try {
server = new ThreadPooledServer(SERVER_PORT, 1, processRequestTester, SERVER_HOST_IP);
} catch (UnknownHostException e1) {
fail();
}
Thread client;
new Thread(server).start();
while (server.isStopped()) {
}
client = new Thread(new ClientRunner(SERVER_HOST_IP));
client.start();
try {
client.join();
} catch (InterruptedException e) {
fail();
}
server.stop();
}
use of java.net.UnknownHostException in project voltdb by VoltDB.
the class DeletesClient method main.
public static void main(String[] args) {
// Use the AppHelper utility class to retrieve command line application parameters
// Define parameters and pull from command line
AppHelper apph = new AppHelper(DeletesClient.class.getCanonicalName()).add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 240).add("average-batch-size", "average_batch_size", "Average batch size", 150000).add("batches", "num_batches_to_keep", "Number of batches to keep", 5).add("cleanup-freq", "cleanup_frequency", "Cleanup frequency, in seconds.", 6).add("snapshot-freq", "cycles_between_snapshots", "Snapshot frequency, in seconds. -1 to turn off snapshots", -1).add("block-snapshots", "use_blocking_snapshots_snapshots", "Blocking snapshots (true|false)", "false").add("small-strings", "use_inline_strings", "Forces all the strings to be inlined strings (true|false)", "false").add("servers", "comma_separated_server_list", "List of VoltDB servers to connect to.", "localhost").setArguments(args);
m_averageBatchSize = apph.intValue("average-batch-size");
m_batchesToKeep = apph.intValue("batches");
m_deceasedCleanupFreq = apph.intValue("cleanup-freq");
m_snapshotFreq = apph.intValue("snapshot-freq");
m_blockingSnapshots = apph.booleanValue("block-snapshots");
m_smallStrings = apph.booleanValue("small-strings");
long duration = apph.longValue("duration");
String commaSeparatedServers = apph.stringValue("servers");
apph.validate("average-batch-size", (m_averageBatchSize > 0));
apph.validate("batches", (m_batchesToKeep >= 0));
apph.validate("duration", (duration >= 0));
apph.validate("cleanup-freq", (m_deceasedCleanupFreq > 0));
apph.printActualUsage();
System.out.println("Starting Deletes app with:");
System.out.printf("\tAverage batch size of %d\n", m_averageBatchSize);
System.out.printf("\tKeeping %d batches\n", m_batchesToKeep);
System.out.printf("\tCleaning up deceased every %d batches\n", m_deceasedCleanupFreq);
System.out.printf("\tSnapshotting every %d batches\n", m_snapshotFreq);
// parse the server list
List<String> servers = new LinkedList<String>();
String[] commaSeparatedServersParts = commaSeparatedServers.split(",");
for (String server : commaSeparatedServersParts) {
servers.add(server.trim());
}
File tmpdir = new File(m_snapshotDir);
tmpdir.mkdir();
generateNames(16);
Client client = null;
ClientConfig config = new ClientConfig("program", "none");
config.setProcedureCallTimeout(Long.MAX_VALUE);
client = ClientFactory.createClient(config);
for (String server : servers) {
try {
client.createConnection(server);
} catch (UnknownHostException e) {
e.printStackTrace();
System.exit(-1);
} catch (IOException e) {
System.err.println("Could not connect to database, terminating: (" + server + ")");
System.exit(-1);
}
}
// Start with the maximum data set we could possibly fill
for (int i = 0; i < m_batchesToKeep; i++) {
insertBatch(client, true);
}
// now add a batch and remove a batch
long deceased_counter = 0;
long snapshot_counter = 0;
long max_batch_counter = 0;
boolean fill_max = false;
long max_batch_remaining = 0;
final long endTime = System.currentTimeMillis() + (1000l * duration);
final long startTime = System.currentTimeMillis();
while (endTime > System.currentTimeMillis()) {
// if (max_batch_counter == m_maxBatchFreq)
// {
// fill_max = true;
// max_batch_remaining = m_batchesToKeep;
// max_batch_counter = 0;
// }
// else if (fill_max)
// {
// max_batch_remaining--;
// fill_max = true;
// if (max_batch_remaining == 0)
// {
// fill_max = false;
// }
// }
// else
// {
// max_batch_counter++;
// fill_max = false;
// }
insertBatch(client, fill_max);
collectStats(client);
snapshot_counter++;
if (snapshot_counter == m_snapshotFreq) {
performSnapshot(client);
snapshot_counter = 0;
}
deceased_counter++;
if (deceased_counter == m_deceasedCleanupFreq) {
deleteDeceased(client);
deceased_counter = 0;
}
countBatch(client, m_batchNumber - m_batchesToKeep - 1);
deleteBatch(client, m_batchesToKeep);
}
System.out.printf("\tTotal runtime: %d seconds\n", (System.currentTimeMillis() - startTime) / 1000l);
}
use of java.net.UnknownHostException in project voltdb by VoltDB.
the class Eng866Client method main.
public static void main(String[] args) {
int hash_preload = Integer.valueOf(args[0]);
String commaSeparatedServers = args[1];
// parse the server list
List<String> servers = new LinkedList<String>();
String[] commaSeparatedServersParts = commaSeparatedServers.split(",");
for (String server : commaSeparatedServersParts) {
servers.add(server.trim());
}
Client client = null;
ClientConfig config = new ClientConfig("program", "none");
client = ClientFactory.createClient(config);
for (String server : servers) {
try {
client.createConnection(server);
} catch (UnknownHostException e) {
e.printStackTrace();
System.exit(-1);
} catch (IOException e) {
System.err.println("Could not connect to database, terminating: (" + server + ")");
System.exit(-1);
}
}
// Fill a bunch of data into the hashtag table so the query will spin
System.out.println("Inserting " + hash_preload + " hashtag entries");
for (int i = 0; i < hash_preload; i++) {
insertNewHashtag(client, randomString(250), m_timestamp++);
}
// pause briefly
while (true) {
System.out.println("Starting cycle: " + m_timestamp);
m_expectedCounts = 2;
String rando = randomString(250);
getHashTags(client, 0, 10);
insertNewTweet(client, rando, m_timestamp);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (m_expectedCounts > 0) {
Thread.yield();
}
System.out.println("Completed cycle");
m_timestamp++;
}
}
use of java.net.UnknownHostException in project voltdb by VoltDB.
the class PullSocketImporterConfig method checkHostAndAddConfig.
private static void checkHostAndAddConfig(String hspec, String procedure, ImmutableMap.Builder<URI, ImporterConfig> builder, FormatterBuilder formatterBuilder) {
Matcher mtc = HOST_RE.matcher(hspec);
if (!mtc.matches()) {
throw new IllegalArgumentException(String.format("Address spec %s is malformed", hspec));
}
int port = Integer.parseInt(mtc.group("port"));
int tail = port;
if (mtc.group("tail") != null) {
tail = Integer.parseInt(mtc.group("tail"));
}
if (port > tail) {
throw new IllegalArgumentException(String.format("Invalid port range in address spec %s", hspec));
}
for (int p = port; p <= tail; ++p) {
InetAddress a;
try {
a = InetAddress.getByName(mtc.group("host"));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(String.format("Failed to resolve host %s", mtc.group("host")), e);
}
InetSocketAddress sa = new InetSocketAddress(a, p);
PullSocketImporterConfig config = new PullSocketImporterConfig(URI.create("tcp://" + sa.getHostString() + ":" + sa.getPort() + "/"), procedure, formatterBuilder);
builder.put(config.getResourceID(), config);
}
}
Aggregations