use of com.aerospike.client.AerospikeClient in project XRTB by benmfaul.
the class AeroRange method main.
public static void main(String[] args) throws Exception {
AerospikeClient client = new AerospikeClient(args[0], 3000);
String skey = "accountingsystem";
Key key = new Key("test", "cache", skey);
while (true) {
Record record = null;
record = client.get(null, key);
String value = (String) record.bins.get("value");
System.out.println(value);
Thread.sleep(1000);
}
}
use of com.aerospike.client.AerospikeClient in project aerospike-client-java by aerospike.
the class SuiteAsync method init.
@BeforeClass
public static void init() {
System.out.println("Begin AerospikeClient");
Args args = Args.Instance;
switch(args.eventLoopType) {
default:
case DIRECT_NIO:
{
eventLoops = new NioEventLoops(1);
break;
}
case NETTY_NIO:
{
EventLoopGroup group = new NioEventLoopGroup(1);
eventLoops = new NettyEventLoops(group);
break;
}
case NETTY_EPOLL:
{
EventLoopGroup group = new EpollEventLoopGroup(1);
eventLoops = new NettyEventLoops(group);
break;
}
}
try {
ClientPolicy policy = new ClientPolicy();
policy.eventLoops = eventLoops;
policy.user = args.user;
policy.password = args.password;
policy.tlsPolicy = args.tlsPolicy;
Host[] hosts = Host.parseHosts(args.host, args.port);
eventLoop = eventLoops.get(0);
client = new AerospikeClient(policy, hosts);
try {
args.setServerSpecific(client);
} catch (RuntimeException re) {
client.close();
throw re;
}
} catch (Exception e) {
eventLoops.close();
throw e;
}
}
use of com.aerospike.client.AerospikeClient in project aerospike-client-java by aerospike.
the class Example method runExamples.
/**
* Connect and run one or more client examples.
*/
public static void runExamples(Console console, Parameters params, List<String> examples) throws Exception {
ClientPolicy policy = new ClientPolicy();
policy.user = params.user;
policy.password = params.password;
policy.tlsPolicy = params.tlsPolicy;
params.policy = policy.readPolicyDefault;
params.writePolicy = policy.writePolicyDefault;
Host[] hosts = Host.parseHosts(params.host, params.port);
AerospikeClient client = new AerospikeClient(policy, hosts);
try {
params.setServerSpecific(client);
for (String exampleName : examples) {
runExample(exampleName, client, params, console);
}
} finally {
client.close();
}
}
use of com.aerospike.client.AerospikeClient in project XRTB by benmfaul.
the class Membership method main.
/**
* Let's test this mess.
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
AerospikeClient client = new AerospikeClient("localhost", 3000);
Membership m = new Membership("c1x-cookies", "/home/ben/Downloads/c1x_cookies.csv", client);
System.out.println(m.query("9786B01215534DEB9AAC2D5FEE23A497"));
}
use of com.aerospike.client.AerospikeClient in project XRTB by benmfaul.
the class RedissonClient method set.
/**
* Set a key value as string with an expiration (No expiration set on cache2k, it is already set
* @param skey String. The key name.
* @param value String. The value.
* @param expire int. The number of seconds before expiring.
* @throws Exception on aerorpike or cache errors.
*/
public void set(String skey, String value, int expire) throws Exception {
if (ae == null) {
cache.put(skey, value);
return;
}
AerospikeClient client = ae.getClient();
if (client == null)
return;
WritePolicy policy = new WritePolicy();
policy.expiration = expire;
Key key = new Key("test", "cache", skey);
Bin bin1 = new Bin("value", value);
ae.getClient().put(policy, key, bin1);
}
Aggregations