@Override public void init() throws DBException { insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY; updatePolicy.recordExistsAction = RecordExistsAction.REPLACE_ONLY; Properties props = getProperties(); namespace = props.getProperty("as.namespace", DEFAULT_NAMESPACE); String host = props.getProperty("as.host", DEFAULT_HOST); String user = props.getProperty("as.user"); String password = props.getProperty("as.password"); int port = Integer.parseInt(props.getProperty("as.port", DEFAULT_PORT)); int timeout = Integer.parseInt(props.getProperty("as.timeout", DEFAULT_TIMEOUT)); readPolicy.timeout = timeout; insertPolicy.timeout = timeout; updatePolicy.timeout = timeout; deletePolicy.timeout = timeout; ClientPolicy clientPolicy = new ClientPolicy(); if (user != null && password != null) { clientPolicy.user = user; clientPolicy.password = password; } try { client = new com.aerospike.client.AerospikeClient(clientPolicy, host, port); } catch (AerospikeException e) { throw new DBException(String.format("Error while creating Aerospike " + "client for %s:%d.", host, port), e); } }
/** * Creates a new {@link ClientPolicyFactoryBean}. */ public ClientPolicyFactoryBean() { this.policy = new ClientPolicy(); }
val policy = new ClientPolicy() val client = new AerospikeClient(policy, initialHost, port) val node = client.getNodes val conn=node(0).getConnection(1000) val info= new Info(conn,"bins/users") val buff:Array[Byte]=info.getBuffer val buffStr=new String(buff)
/** * Initialize Aerospike client. * If the host connection succeeds, the client will: * <p> * - Add host to the cluster map <br> * - Request host's list of other nodes in cluster <br> * - Add these nodes to cluster map <br> * <p> * If the connection succeeds, the client is ready to process database requests. * If the connection fails, the cluster will remain in a disconnected state * until the server is activated. * * @param hostname host name * @param port host port * @throws AerospikeException if host connection fails */ public AerospikeClient(String hostname, int port) throws AerospikeException { this(new ClientPolicy(), new Host(hostname, port)); }
/** * Initialize Aerospike client. * If the host connection succeeds, the client will: * <p> * - Add host to the cluster map <br> * - Request host's list of other nodes in cluster <br> * - Add these nodes to cluster map <br> * <p> * If the connection succeeds, the client is ready to process database requests. * If the connection fails, the cluster will remain in a disconnected state * until the server is activated. * * @param hostname host name * @param port host port * @throws AerospikeException if host connection fails */ public AerospikeClient(String hostname, int port) throws AerospikeException { this(new ClientPolicy(), new Host(hostname, port)); }
private static AerospikeClient getAerospikeClient(CommandLine cl) { ClientPolicy clientPolicy = new ClientPolicy(); initClientPolicy(cl, clientPolicy); AerospikeClient client = new AerospikeClient(clientPolicy, params.hosts); if (!client.isConnected()) { log.error("Client is not able to connect:" + params.hosts); return null; } try { // Check read-write role is given to user. if (!client.queryUser(null, clientPolicy.user).roles.contains(Role.ReadWrite)) { log.error("User role:" + client.queryUser(null, clientPolicy.user).roles.toString() + " Expected:" + Role.ReadWrite); return null; } } catch (AerospikeException e) { // Ignore if security is not enabled. } return client; }
policy = new ClientPolicy();
policy = new ClientPolicy();
/** * 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.authMode = params.authMode; 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(); } }
aerospikeParameters = new AerospikeParameters(aerospikeMappingBuilder.getAerospikeMapping(), properties, getConf()); ClientPolicy policy = new ClientPolicy(); policy.writePolicyDefault = aerospikeParameters.getAerospikeMapping().getWritePolicy(); policy.readPolicyDefault = aerospikeParameters.getAerospikeMapping().getReadPolicy();
ClientPolicy policy = new ClientPolicy(); policy.eventLoops = eventLoops; policy.user = params.user;
aerospikeParameters = new AerospikeParameters(aerospikeMappingBuilder.getAerospikeMapping(), properties, getConf()); ClientPolicy policy = new ClientPolicy(); policy.writePolicyDefault = aerospikeParameters.getAerospikeMapping().getWritePolicy(); policy.readPolicyDefault = aerospikeParameters.getAerospikeMapping().getReadPolicy();