use of org.questdb.examples.support.Price in project questdb by bluestreak01.
the class AuthReplicationClientMain method main.
public static void main(String[] args) throws Exception {
JournalConfiguration configuration = new JournalConfigurationBuilder().build(args[0]);
Factory factory = new Factory(configuration);
final JournalClient client = new JournalClient(factory, () -> "MY SECRET".getBytes("UTF8"));
final Journal<Price> reader = factory.reader(Price.class, "price-copy");
reader.setSequentialAccess(true);
client.subscribe(Price.class, null, "price-copy", new JournalListener() {
@Override
public void onCommit() {
int count = 0;
long t = 0;
for (Price p : JournalIterators.incrementBufferedIterator(reader)) {
if (count == 0) {
t = p.getNanos();
}
count++;
}
System.out.println("took: " + (System.nanoTime() - t) + ", count=" + count);
}
@Override
public void onEvent(int event) {
System.out.println("There was an error");
}
});
client.start();
System.out.println("Client started");
}
use of org.questdb.examples.support.Price in project questdb by bluestreak01.
the class ClusteredProducerMain method main.
public static void main(String[] args) throws JournalException, IOException, JournalNetworkException, NumericException {
final String pathToDatabase = args[0];
final int instance = Numbers.parseInt(args[1]);
final JournalConfiguration configuration = new JournalConfigurationBuilder() {
{
$(Price.class).$ts();
}
}.build(pathToDatabase);
final Factory factory = new Factory(configuration, 1000, 1, 0);
final JournalWriter<Price> writer = factory.writer(new JournalKey<>(Price.class, null, PartitionBy.DEFAULT, 1000000000));
final WorkerController wc = new WorkerController(writer);
final ClusterController cc = new ClusterController(new ServerConfig() {
{
addNode(new ServerNode(1, "127.0.0.1:7080"));
addNode(new ServerNode(2, "127.0.0.1:7090"));
}
}, new ClientConfig(), factory, instance, new ArrayList<JournalWriter>() {
{
add(writer);
}
}, wc);
cc.start();
Runtime.getRuntime().addShutdownHook(new Thread(cc::halt));
}
use of org.questdb.examples.support.Price in project questdb by bluestreak01.
the class SimpleReplicationClientMain method main.
public static void main(String[] args) throws Exception {
JournalConfiguration configuration = new JournalConfigurationBuilder().build(args[0]);
Factory factory = new Factory(configuration, 1000, 1, 0);
final JournalClient client = new JournalClient(factory);
final Journal<Price> reader = factory.reader(Price.class, "price-copy");
reader.setSequentialAccess(true);
client.subscribe(Price.class, null, "price-copy", new JournalListener() {
@Override
public void onCommit() {
int count = 0;
long t = 0;
for (Price p : JournalIterators.incrementBufferedIterator(reader)) {
if (count == 0) {
t = p.getNanos();
}
count++;
}
System.out.println("took: " + (System.nanoTime() - t) + ", count=" + count);
}
@Override
public void onEvent(int event) {
System.out.println("There was an error");
}
});
client.start();
System.out.println("Client started");
}
use of org.questdb.examples.support.Price in project questdb by bluestreak01.
the class SimpleReplicationServerMain method start.
public void start() throws Exception {
JournalConfiguration configuration = new JournalConfigurationBuilder().build(location);
Factory factory = new Factory(configuration, 1000, 1, 0);
JournalServer server = new JournalServer(factory);
JournalWriter<Price> writer = factory.writer(Price.class);
server.publish(writer);
server.start();
System.out.print("Publishing: ");
for (int i = 0; i < 10; i++) {
publishPrice(writer, i < 3 ? 1000000 : 100);
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
System.out.print('.');
}
System.out.println(" [Done]");
}
use of org.questdb.examples.support.Price in project questdb by bluestreak01.
the class SslReplicationClientMain method main.
public static void main(String[] args) throws Exception {
JournalConfiguration configuration = new JournalConfigurationBuilder().build(args[0]);
Factory factory = new Factory(configuration, 1000, 1, 0);
final JournalClient client = new JournalClient(new ClientConfig() {
{
getSslConfig().setSecure(true);
try (InputStream is = this.getClass().getResourceAsStream("/keystore/singlekey.ks")) {
getSslConfig().setTrustStore(is, "changeit");
}
}
}, factory);
final Journal<Price> reader = factory.reader(Price.class, "price-copy");
reader.setSequentialAccess(true);
client.subscribe(Price.class, null, "price-copy", new JournalListener() {
@Override
public void onCommit() {
int count = 0;
long t = 0;
for (Price p : JournalIterators.incrementBufferedIterator(reader)) {
if (count == 0) {
t = p.getNanos();
}
count++;
}
System.out.println("took: " + (System.nanoTime() - t) + ", count=" + count);
}
@Override
public void onEvent(int event) {
System.out.println("There was an error");
}
});
client.start();
System.out.println("Client started");
}
Aggregations