public class ConfInternal extends Object
com.tailf.proto
package.
It is used internally by the API and
thus should not be used by user of this API directly.
This class is a translation of the C library confd_internal.c.
Constructor and Description |
---|
ConfInternal() |
Modifier and Type | Method and Description |
---|---|
static void |
bufWrite(SelectionKey key,
int cdbop,
int thandle,
byte[] buf)
Writes OP + string
|
static void |
bufWrite(Socket socket,
int cdbop,
int thandle,
byte[] buf)
Writes OP + string
|
static void |
diffIterate(Object socket,
ConfIterate iter,
Object initstate) |
static void |
diffIterate(SelectionKey key,
ConfIterate iter,
Object initstate)
Common static method for diffIterate with CdbSubscription.
|
static long |
doConnect(SelectionKey key,
int id)
Connects the provided selectable channel to the Erlang process
using the supplied selector with the buffer buf with the identifier
id.
|
static long |
doConnect(Socket socket,
int id) |
static void |
flushToSocket(Object socket,
ConfOutputStream out) |
static void |
flushToSocket(SelectionKey key,
ConfOutputStream out) |
static int |
get_int16(int offset,
byte[] s) |
static long |
get_int32(int offset,
byte[] s) |
static ConfObject[] |
hk_keypath(ConfEObject term)
Create a hkeypath from a term.
|
static void |
intWrite(Socket socket,
int cdbop,
int thandle,
int arg)
Writes an integer op, a thandle, and a single integer argument to
ConfD/NCS.
|
static ConfObject[] |
mk_keypath(ConfEObject term,
ArrayList<ConfNamespace> ns_list)
Makes a keypath from a term.
|
static void |
put_int16(int offset,
int i,
byte[] s) |
static void |
put_int32(int offset,
int i,
byte[] s) |
static void |
readFill(SelectionKey key,
ByteBuffer buf,
int siz)
Read exactly
siz data into the buffer
buf . |
static void |
readFill(Socket socket,
byte[] b)
Reads data into a buffer.
|
static void |
readPayLoad(SelectionKey key,
ByteBuffer buf,
int size) |
static void |
readSize(SelectionKey key,
ByteBuffer buf,
int size) |
static int |
requestInt(Socket socket,
int op)
Request an integer from ConfD/NCS.
|
static int |
requestInt(Socket socket,
int op,
int thandle)
Requests an integer value from ConfD/NCS.
|
static ConfResponse |
requestTerm(SelectionKey key,
int op)
Request the operation
op with no argument,
and read the response from ConfD/NCS. |
static ConfResponse |
requestTerm(SelectionKey key,
int op,
ConfEObject arg)
Write a term
arg for the specified operation
op and read the response,
from ConfD/NCS. |
static ConfResponse |
requestTerm(SelectionKey key,
int op,
int thandle,
boolean isrel,
ConfEObject arg)
Write a term
arg for the specified operation
op , transaction handle thandle
( if available -1 otherwise ) and read the response,
from ConfD/NCS. |
static ConfResponse |
requestTerm(Socket socket,
int op)
Requests a term from ConfD/NCS.
|
static ConfResponse |
requestTerm(Socket socket,
int op,
ConfEObject arg)
Requests a term from ConfD/NCS.
|
static ConfResponse |
requestTerm(Socket socket,
int op,
int thandle,
boolean isrel,
ConfEObject arg)
Requests a term from ConfD/NCS.
|
static String |
substitute_percent(String fmt,
Object... arguments) |
static ConfResponse |
termRead(Object sock)
Common method to read a term from ConfD/NCS
NOTE: This method should not be used by users of this API.
|
static ConfResponse |
termRead(SelectionKey key)
Common method to read ( request ) a term from ConfD/NCS
NOTE: This method should not be used by users of this API.
|
static ConfResponse |
termRead(SelectionKey key,
int cdbop)
Read a response, term from ConfD/NCS with the
given
SelectionKey and the op cdbop . |
static ConfResponse |
termRead(Socket sock)
Request one term from ConfD/NCS.
|
static ConfResponse |
termRead(Socket sock,
int cdbop)
Request one term from ConfD/NCS.
|
static byte[] |
termWrite(int cdbop,
int thandle,
ConfEObject term) |
static void |
termWrite(SelectionKey key,
int cdbop,
int thandle,
ConfEObject term)
Request that the operation
op should be performed,
with argument term term and with the transaction handle
thandle to ConfD/NCS. |
static void |
termWrite(Socket socket,
ConfEObject term)
Writes a term argument to ConfD/NCS.
|
static void |
termWrite(Socket socket,
int op,
ConfEObject term)
Writes a term argument to ConfD/NCS.
|
static void |
termWrite(Socket socket,
int cdbop,
int thandle,
ConfEObject term)
Writes a term argument to ConfD/NCS.
|
static byte[] |
write(int op,
int thandle) |
static void |
write(SelectionKey key,
int op,
int thandle)
Request that the operation
op should be performed,
with no argument and with the transaction handle
thandle to ConfD/NCS. |
static void |
write(Socket socket,
int op)
Write a simple op to ConfD/NCS
|
static void |
write(Socket socket,
int op,
int thandle)
Writes an op and a transaction handle to ConfD/NCS.
|
public static long get_int32(int offset, byte[] s)
public static int get_int16(int offset, byte[] s)
public static void put_int32(int offset, int i, byte[] s)
public static void put_int16(int offset, int i, byte[] s)
public static ConfResponse termRead(Socket sock) throws ConfException, IOException
sock
- A socket connected to ConfD/NCSConfException
IOException
public static ConfResponse termRead(SelectionKey key) throws ConfException, IOException
key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static ConfResponse termRead(Object sock) throws ConfException, IOException
sock
- Either instance of a Socket or a SocketChannel.IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static ConfResponse termRead(Socket sock, int cdbop) throws ConfException, IOException
sock
- A socket connected to ConfD/NCScdbop
- The op codeConfException
IOException
public static ConfResponse termRead(SelectionKey key, int cdbop) throws ConfException, IOException
SelectionKey
and the op cdbop
.
NOTE: This method is called by Cdb when used with a
SocketChannel
and should not be used directly
by the user of this API.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static void readFill(Socket socket, byte[] b) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSb
- Buffer array of bytes to read data intoConfException
IOException
public static void readSize(SelectionKey key, ByteBuffer buf, int size) throws ConfException, IOException
ConfException
IOException
public static void readPayLoad(SelectionKey key, ByteBuffer buf, int size) throws ConfException, IOException
ConfException
IOException
public static void readFill(SelectionKey key, ByteBuffer buf, int siz) throws ConfException, IOException
siz
data into the buffer
buf
.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS. NOTE: The attached buffer is supplied from
the readPayLoad method only!buf
- ByteBuffer of bytes to read data intosiz
- The number of bytes to read into the buffer buf
IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static ConfResponse requestTerm(Socket socket, int op, int thandle, boolean isrel, ConfEObject arg) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSop
- The op code.isrel
- Boolean flag that says that if the provided arg is a path
if it is relative or notarg
- Argument ConfObject objectConfException
IOException
public static ConfResponse requestTerm(SelectionKey key, int op, int thandle, boolean isrel, ConfEObject arg) throws ConfException, IOException
arg
for the specified operation
op
, transaction handle thandle
( if available -1 otherwise ) and read the response,
from ConfD/NCS.
The isrel
parameter determines if the term
written contains path that should treated as a relative.
NOTE: This method is called by Cdb when used with a
SocketChannel
and should not be used directly
by the user of this API.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.op
- The operation performed on ConfD/NCSthandle
- The transaction handle ( if Maapi) -1 otherwiseisrel
- Determines if the operation is relativearg
- The argument term to the operation op
op
IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static ConfResponse requestTerm(Socket socket, int op) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSop
- The op code.ConfException
IOException
public static ConfResponse requestTerm(SelectionKey key, int op) throws ConfException, IOException
op
with no argument,
and read the response from ConfD/NCS.
Specifying the operation as not relative.
The isrel
parameter determines if the term
written contains path that should treated as a relative.
Request a term for the specified operation
op
.
NOTE: This method is called by Cdb when used with a
SocketChannel
and should not be used directly
by the user of this API.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.op
- The operation performed on ConfD/NCSop
IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static ConfResponse requestTerm(Socket socket, int op, ConfEObject arg) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSop
- The op code.arg
- An argument to send in the requestConfException
IOException
public static ConfResponse requestTerm(SelectionKey key, int op, ConfEObject arg) throws ConfException, IOException
arg
for the specified operation
op
and read the response,
from ConfD/NCS.
Specifying the operation as not relative.
NOTE: This method is called by Cdb when used with a
SocketChannel
and should not be used directly
by the user of this API.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.op
- The operation performed on ConfD/NCSop
IOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static int requestInt(Socket socket, int op, int thandle) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSop
- The op code.thandle
- The transaction handle.ConfException
IOException
public static int requestInt(Socket socket, int op) throws ConfException, IOException
socket
- A socket connected to ConfD/NCSop
- The op code.ConfException
IOException
public static void write(Socket socket, int op, int thandle) throws IOException
socket
- A socket connected to ConfD/NCSop
- The op code.IOException
public static void write(SelectionKey key, int op, int thandle) throws IOException
op
should be performed,
with no argument and with the transaction handle
thandle
to ConfD/NCS.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.op
- The operation performed on ConfD/NCSthandle
- The transaction handle ( if Maapi) -1 otherwiseIOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static byte[] write(int op, int thandle) throws IOException
IOException
public static void write(Socket socket, int op) throws IOException
socket
- A socket connected to ConfD/NCSop
- The op code.IOException
public static void intWrite(Socket socket, int cdbop, int thandle, int arg) throws IOException
socket
- A socket connected to ConfD/NCScdbop
- The op code.IOException
public static void termWrite(Socket socket, int cdbop, int thandle, ConfEObject term) throws IOException
socket
- A socket connected to ConfD/NCScdbop
- The op code.thandle
- The transaction handleterm
- The ConfEObject term to write.IOException
public static void termWrite(SelectionKey key, int cdbop, int thandle, ConfEObject term) throws IOException
op
should be performed,
with argument term term
and with the transaction handle
thandle
to ConfD/NCS.key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.cdbop
- The operation performed on ConfD/NCSthandle
- The transaction handle ( if Maapi) -1 otherwise
usually when Cdbterm
- The argument term to the operation op
IOException
- if an general I/O error occurredpublic static byte[] termWrite(int cdbop, int thandle, ConfEObject term) throws IOException
IOException
public static void termWrite(Socket socket, int op, ConfEObject term) throws IOException
socket
- A socket connected to ConfD/NCSop
- The op code.term
- The ConfEObject term to write.IOException
public static void termWrite(Socket socket, ConfEObject term) throws IOException
socket
- A socket connected to ConfD/NCSterm
- The ConfEObject term to write.IOException
public static void bufWrite(Socket socket, int cdbop, int thandle, byte[] buf) throws IOException
socket
- A socket connected to ConfD/NCScdbop
- The op code.thandle
- The transaction handlebuf
- The byte buffer to writeIOException
public static void bufWrite(SelectionKey key, int cdbop, int thandle, byte[] buf) throws IOException
key
- A socket connected to ConfD/NCScdbop
- The op code.thandle
- The transaction handlebuf
- The byte buffer to writeIOException
public static ConfObject[] mk_keypath(ConfEObject term, ArrayList<ConfNamespace> ns_list) throws ConfException
ConfException
public static ConfObject[] hk_keypath(ConfEObject term) throws ConfException
term
- - A HKey path as ConfEListConfException
public static long doConnect(Socket socket, int id) throws ConfException
ConfException
public static long doConnect(SelectionKey key, int id) throws ConfException, IOException
key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.id
- the integer which specifies what kind of socket
( should always be CdbProto.OP_CLIENT_NAME )ConfException
- If the IPCAccessSecret check
throws IOException it will be wrapped inside the ConfExcepion
to be able to retrieve the cause use getCause().IOException
- if an I/O error occuredpublic static void diffIterate(Object socket, ConfIterate iter, Object initstate) throws IOException, ConfException
IOException
ConfException
public static void diffIterate(SelectionKey key, ConfIterate iter, Object initstate) throws IOException, ConfException
key
- The registration representation of a particular
channel object with a particular selector object.
The key parameter is not part of the "ready set" but its
internal "interest set" has been registered with the selector.
The key's attachment holds a reference to the
ByteBuffer that is used to read/write bytes from/to
ConfD/NCS.iter
- The callback user codeinitstate
- The opaque object passed from user codeIOException
- if an general I/O error occurredConfException
- if ConfD/NCS protocol error occurredpublic static void flushToSocket(SelectionKey key, ConfOutputStream out) throws IOException
IOException
public static void flushToSocket(Object socket, ConfOutputStream out) throws IOException
IOException