public class Session extends Object implements AutoCloseable
An Usage Example:
Following code will open a connection with a chmpx slave process and close it.
import ax.antpick.k2hdkc.*;
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import java.io.IOException;
public class App {
private static final String CHMPX_SLAVE_CONFIG = "cluster/slave.yaml";
public static void main(String[] args) {
try (Cluster c = Cluster.of(CHMPX_SLAVE_CONFIG);
Session s = Session.of(c); ) {
System.out.println(s.toString()); // prints session information.
} catch (IOException ex) {
System.out.println(ex.getMessage());
assert (false);
}
}
}
Before running the code above, You should run three processes.
The following commands in this repository will run all processes you need in localhost.
$ cd cluster
$ sh start_server.sh
, Hirotaka WakabayashiModifier and Type | Field and Description |
---|---|
static long |
K2HASH_INVALID_HANDLE
k2hash default handle
|
static long |
K2HDKC_INVALID_HANDLE
k2hdkc default handle
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes a connection with a chmpx slave process.
|
long |
getHandle()
Returns a k2hash data handle.
|
static Session |
of(Cluster cluster)
Creates a Session instance.
|
String |
toString()
Returns full of members as a string.
|
public static final long K2HDKC_INVALID_HANDLE
public static final long K2HASH_INVALID_HANDLE
public String toString()
public static Session of(Cluster cluster) throws IOException
cluster
- a k2hdkc cluster instanceIllegalArgumentException
- if pathname should not be nullIOException
- if creating a chmpx configuration
file failedpublic void close() throws IOException
close
in interface AutoCloseable
IOException
- will not be thrown from this class even if k2hdkc_close_chmpx_ex returns
false because it's not critical.Copyright © 2020. All rights reserved.