/** * Get default info from the specified database server node, using host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @return info name/value pairs */ public static HashMap<String,String> request(String hostname, int port) throws AerospikeException { return request(new InetSocketAddress(hostname, port)); }
/** * Get default info from the specified database server node, using host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @return info name/value pairs */ public static HashMap<String,String> request(String hostname, int port) throws AerospikeException { return request(new InetSocketAddress(hostname, port)); }
/** * Get many info values by name from the specified database server node, * using host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @param names names of values to retrieve * @return info name/value pairs */ public static HashMap<String,String> request(String hostname, int port, String... names) throws AerospikeException { return request(new InetSocketAddress(hostname, port), names); }
/** * Get one info value by name from the specified database server node, using * host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @param name name of value to retrieve * @return info value */ public static String request(String hostname, int port, String name) throws AerospikeException { return request(new InetSocketAddress(hostname, port), name); }
/** * Get many info values by name from the specified database server node, * using host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @param names names of values to retrieve * @return info name/value pairs */ public static HashMap<String,String> request(String hostname, int port, String... names) throws AerospikeException { return request(new InetSocketAddress(hostname, port), names); }
/** * Get one info value by name from the specified database server node, using * host name and port. * This method does not support user authentication. * * @param hostname host name * @param port host port * @param name name of value to retrieve * @return info value */ public static String request(String hostname, int port, String name) throws AerospikeException { return request(new InetSocketAddress(hostname, port), name); }
@Override public long count(Class<?> type, String setName) { Assert.notNull(type, "Type for count must not be null!"); Node[] nodes = client.getNodes(); int replicationCount = 2; int nodeCount = nodes.length; int n_objects = 0; for (Node node : nodes) { String infoString = Info.request(node, "sets/" + this.namespace + "/" + setName); String n_objectsString = infoString.substring( infoString.indexOf("=") + 1, infoString.indexOf(":")); n_objects = Integer.parseInt(n_objectsString); } return (nodeCount > 1) ? n_objects / replicationCount : n_objects; }
public String[] getNamespaceConfig(String namespace) { String build = null; Node[] nodes = synClient.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } return Info.request(synClient.getInfoPolicyDefault(), nodes[0], CONFIG_NAMESPACE + namespace).split(";"); }
public int getReplicationFactor(String namespace) { Node[] nodes = synClient.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } String[] configStrings = Info.request(synClient.getInfoPolicyDefault(), nodes[0], CONFIG_NAMESPACE + namespace).split(";"); for (String configString : configStrings) { String[] configLine = configString.split("="); if (configLine.length == 2 && configLine[0].equals(REPLICATION_FACTOR)) { return Integer.valueOf(configLine[1]); } } return 1; }
/** * Fetches all namespaces available in database.. * * @return A set of namespaces */ public Set<String> getNamespaces() { Set<String> nsNames = new HashSet<>(); Node[] nodes = synClient.getNodes(); for (Node node : nodes) { String nodeNsNames = Info.request(synClient.getInfoPolicyDefault(), node, CONFIG_NAMESPACES_PARAM); String[] nsNamesArray = nodeNsNames.split(";"); Collections.addAll(nsNames, nsNamesArray); } return nsNames; }
/** * Query namespace configuration. */ private void GetNamespaceConfig(Node node, Parameters params) throws Exception { console.write("Namespace Configuration"); String filter = "namespace/" + params.namespace; String tokens = Info.request(null, node, filter); if (tokens == null) { throw new Exception(String.format( "Failed to get namespace info: host=%s port=%d namespace=%s", params.host, params.port, params.namespace)); } LogNameValueTokens(tokens); }
public boolean isUDFEnabled(String namespace) { Node[] nodes = synClient.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } String[] config = Info.request(synClient.getInfoPolicyDefault(), nodes[0], CONFIG_NAMESPACE + namespace).split(";"); return Boolean.valueOf(parseConfigString(config, "ldt-enabled", "false")); }
public long getDefaultTTL(String namespace) { Node[] nodes = synClient.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } String[] config = Info.request(synClient.getInfoPolicyDefault(), nodes[0], CONFIG_NAMESPACE + namespace).split(";"); return Long.valueOf(parseConfigString(config, "default-ttl", "0")); }
public static long validateBegin(Node node, String namespace) { if (! node.hasClusterStable()) { return 0; } // Fail when cluster is in migration. String result = Info.request(node, "cluster-stable:namespace=" + namespace); try { return Long.parseLong(result, 16); } catch (Exception e) { // Yes, even scans return QUERY_ABORTED. throw new AerospikeException(ResultCode.QUERY_ABORTED, "Cluster is in migration: " + result); } }
/** * Returns the server build. * * @return server build string */ public Build getServerBuild() { String build = null; Node[] nodes = synClient.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } build = Info.request(synClient.getInfoPolicyDefault(), nodes[0], CONFIG_BUILD); String[] buildNumbers = build.split("\\."); return new Build(Integer.valueOf(buildNumbers[0]), Integer.valueOf(buildNumbers[1]), Integer.valueOf(buildNumbers[2])); }
public static long validateBegin(Node node, String namespace) { if (! node.hasClusterStable()) { return 0; } // Fail when cluster is in migration. String result = Info.request(node, "cluster-stable:namespace=" + namespace); try { return Long.parseLong(result, 16); } catch (Exception e) { // Yes, even scans return QUERY_ABORTED. throw new AerospikeException(ResultCode.QUERY_ABORTED, "Cluster is in migration: " + result); } }
/** * Private helper method to get servers build number. * * @param client Native Aerospike client * @return Server build version as InfoFetcher.Build */ public static InfoFetcher.Build getServerBuild(IAerospikeClient client) { Node[] nodes = client.getNodes(); if (nodes == null || nodes.length == 0) { throw new IllegalStateException("No Aerospike nodes found."); } String build = Info.request(asyncClient.getInfoPolicyDefault(), nodes[0], "build"); String[] buildNumbers = build.split("\\."); return new InfoFetcher.Build(Integer.valueOf(buildNumbers[0]), Integer.valueOf(buildNumbers[1]), Integer.valueOf(buildNumbers[2])); } }
public static Version getServerVersion(AerospikeClient client, InfoPolicy policy) { Node node = client.getNodes()[0]; String response = Info.request(policy, node, "build"); return new Version(response); }
public static Version getServerVersion(AerospikeClient client, InfoPolicy policy) { Node node = client.getNodes()[0]; String response = Info.request(policy, node, "build"); return new Version(response); }
@Override public boolean indexExists(String indexName) { //TODO: should be moved to aerospike-client try { Node[] nodes = client.getNodes(); if (nodes.length == 0) { throw new AerospikeException.InvalidNode(); } Node node = nodes[0]; String response = Info.request(node, "sindex/" + namespace + '/' + indexName); return !response.startsWith("FAIL:201"); } catch (AerospikeException e) { DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e); throw translatedException == null ? e : translatedException; } }