public class JDBC_PING extends FILE_PING
Discovery protocol using a JDBC connection to a shared database.
Connection options can be defined as configuration properties, or the JNDI
name of a DataSource
can be provided (avoid providing both).
Both the schema and the used SQL statements can be customized; make sure the order of parameters of such customized SQL statements is maintained and that compatible types are used for the columns. The recommended schema uses a single table, with two String columns being used primary key (local address, cluster name) and a third column to store the serialized form of the objects needed by JGroups.
A default table will be created at first connection, errors during this
operation are not considered critical. Set the initialize_sql
to an empty value to prevent this initial table creation, or change it to
create a customized table.
FILE_PING.WriterTask
Discovery.Responses
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
connection_driver |
protected java.lang.String |
connection_password |
protected java.lang.String |
connection_url |
protected java.lang.String |
connection_username |
protected java.lang.String |
datasource_jndi_name |
protected java.lang.String |
delete_single_sql |
protected java.lang.String |
initialize_sql |
protected java.lang.String |
insert_single_sql |
protected java.lang.String |
select_all_pingdata_sql |
filter, interval, location, root_dir, SUFFIX
group_addr, local_addr, members, ping_responses, rank, timer, view
Constructor and Description |
---|
JDBC_PING() |
Modifier and Type | Method and Description |
---|---|
protected void |
attemptSchemaInitialization() |
protected void |
closeConnection(java.sql.Connection connection) |
protected void |
createRootDir() |
protected void |
delete(java.sql.Connection connection,
java.lang.String clustername,
java.lang.String addressToDelete) |
protected void |
delete(java.lang.String clustername,
java.lang.String addressToDelete) |
protected void |
deleteSelf() |
protected PingData |
deserialize(byte[] data) |
protected java.sql.Connection |
getConnection() |
protected javax.sql.DataSource |
getDataSourceFromJNDI(java.lang.String name) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected void |
insert(java.sql.Connection connection,
PingData data,
java.lang.String clustername,
java.lang.String address) |
protected void |
loadDriver() |
protected java.util.List<PingData> |
readAll(java.sql.Connection connection,
java.lang.String clustername) |
protected java.util.List<PingData> |
readAll(java.lang.String clustername)
Reads all information from the given directory under clustername
|
protected void |
remove(java.lang.String clustername,
Address addr) |
protected byte[] |
serializeWithoutView(PingData data)
Creates a byte[] representation of the PingData, but DISCARDING
the view it contains.
|
void |
stop()
This method is called on a
Channel.disconnect() . |
protected void |
verifyconfigurationParameters() |
protected void |
writeToFile(PingData data,
java.lang.String clustername) |
addressAsString, down, handleView, readFile, sendGetMembersRequest, start
discoveryRequestReceived, findAllMembers, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembers, findInitialMembersAsString, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getNumPingRequests, getTimeout, getView, handleConnect, handleDisconnect, makeView, providedUpServices, resetStats, setNumInitialMembers, setNumPingRequests, setTimeout, up
destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, upThreadEnabled
protected java.lang.String connection_url
protected java.lang.String connection_username
protected java.lang.String connection_password
protected java.lang.String connection_driver
protected java.lang.String initialize_sql
protected java.lang.String insert_single_sql
protected java.lang.String delete_single_sql
protected java.lang.String select_all_pingdata_sql
protected java.lang.String datasource_jndi_name
public void init() throws java.lang.Exception
Protocol
public void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushedprotected void attemptSchemaInitialization()
protected void loadDriver()
protected java.sql.Connection getConnection()
protected void createRootDir()
createRootDir
in class FILE_PING
protected void remove(java.lang.String clustername, Address addr)
protected java.util.List<PingData> readAll(java.lang.String clustername)
FILE_PING
protected java.util.List<PingData> readAll(java.sql.Connection connection, java.lang.String clustername) throws java.sql.SQLException
java.sql.SQLException
protected void writeToFile(PingData data, java.lang.String clustername)
writeToFile
in class FILE_PING
protected void insert(java.sql.Connection connection, PingData data, java.lang.String clustername, java.lang.String address) throws java.sql.SQLException
java.sql.SQLException
protected void delete(java.sql.Connection connection, java.lang.String clustername, java.lang.String addressToDelete) throws java.sql.SQLException
java.sql.SQLException
protected void delete(java.lang.String clustername, java.lang.String addressToDelete) throws java.sql.SQLException
java.sql.SQLException
protected void deleteSelf() throws java.sql.SQLException
java.sql.SQLException
protected byte[] serializeWithoutView(PingData data)
data
- the PingData instance to serialize.protected PingData deserialize(byte[] data)
protected void closeConnection(java.sql.Connection connection)
protected javax.sql.DataSource getDataSourceFromJNDI(java.lang.String name)
protected void verifyconfigurationParameters()
Copyright ? 1998-2009 Bela Ban / Red Hat. All Rights Reserved.