Package uk.co.sculptor.kflibjava
Class Realm
java.lang.Object
uk.co.sculptor.kflibjava.Realm
- All Implemented Interfaces:
AutoCloseable
Realm where servers live. Used to define the transaction scope.
Note: This class implements theAutoCloseable
interface, meaning that an object may hold resources
(such as file or socket handles) until it is closed. The close() method of an AutoCloseable object is called automatically
when exiting a try-with-resources
block for which the object has been declared in the resource specification header.
This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.- Author:
- Marcos Gutierrez Batz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
begin()
Begin transaction on all the servers that belong to the current Realm.void
close()
Close all Servers hanging from the realmvoid
commit()
Commit transaction on all the servers that belong to the current Realm.Get the current Realm provided nameopenServer
(String serverName) Create aServer
object.openServer
(String serverName, int timeOut) Create aServer
object.void
rollBack()
Roll back transaction on all the servers that belong to the current Realm.void
sendKeepAlives
(long intervalSecs) Send Keep Alives to all the Realm Servers (programs must use their own timer).
-
Constructor Details
-
Realm
Constructor: Create the Realm object- Parameters:
realmName
- The realm name.
-
-
Method Details
-
begin
Begin transaction on all the servers that belong to the current Realm.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- When a protocol error or a server error is detected.
-
close
Close all Servers hanging from the realm- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- If an I/O error occurs when dealing with the socketKfException
- Any error on the KfServer protocol or on the server closing process.
-
commit
Commit transaction on all the servers that belong to the current Realm.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- When a protocol error or a server error is detected.
-
getRealmName
Get the current Realm provided name- Returns:
- the realmName
-
openServer
Create aServer
object.- Parameters:
serverName
- The server name where the KfServer process is executing- Returns:
- the Server object to be used to create Databases
- Throws:
KfException
- Any error on the KfServer protocol or parameters.IOException
- If an I/O error occurs when using the socket.InterruptedException
- If an interrupt is received while waiting for next connection retry.
-
openServer
public Server openServer(String serverName, int timeOut) throws KfException, IOException, InterruptedException Create aServer
object.- Parameters:
serverName
- The server name where the KfServer process is executingtimeOut
- Seconds to try the server connection (-1 means default value, 15 seconds)- Returns:
- the Server object to be used to create Databases
- Throws:
KfException
- Any error on the KfServer protocol or parameters.IOException
- If an I/O error occurs when using the socket.InterruptedException
- If an interrupt is received while waiting for next connection retry.
-
rollBack
Roll back transaction on all the servers that belong to the current Realm.- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- When a protocol error or a server error is detected.
-
sendKeepAlives
Send Keep Alives to all the Realm Servers (programs must use their own timer).- Parameters:
intervalSecs
- Keep alive interval- Throws:
IOException
- Any error received by writing/reading the socket.KfException
- When a protocol error or a server error is detected.
-