public class JDBC_PING extends Discovery
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.
Modifier and Type | Class and Description |
---|---|
protected class |
JDBC_PING.InfoWriter
Class which calls writeOwnInformation a few times.
|
Discovery.DiscoveryCacheDisseminationTask
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
clear_sql |
protected boolean |
clear_table_on_view_change |
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 |
contains_sql |
protected java.lang.String |
datasource_jndi_name |
protected java.lang.String |
delete_single_sql |
protected java.util.concurrent.Future<?> |
info_writer |
protected int |
info_writer_max_writes_after_view |
protected long |
info_writer_sleep_time |
protected java.lang.String |
initialize_sql |
protected java.lang.String |
insert_single_sql |
protected boolean |
register_shutdown_hook |
protected java.lang.String |
select_all_pingdata_sql |
always_send_physical_addr_with_discovery_request, async_discovery, async_discovery_use_separate_thread_per_request, break_on_coord_rsp, cluster_name, current_coord, discovery_rsp_expiry_time, force_sending_discovery_rsps, is_coord, is_leaving, is_server, local_addr, max_members_in_discovery_request, members, num_discovery_requests, num_initial_members, num_initial_srv_members, ping_responses, return_entire_cache, send_cache_on_join, stagger_timeout, timeout, timer, transport_supports_multicasting, use_disk_cache, view, WHITESPACE
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
JDBC_PING() |
Modifier and Type | Method and Description |
---|---|
protected void |
attemptSchemaInitialization() |
protected void |
clearTable() |
protected void |
closeConnection(java.sql.Connection connection) |
protected boolean |
contains(java.lang.String cluster_name,
Address addr) |
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() |
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
void |
findMembers(java.util.List<Address> members,
boolean initial_discovery,
Responses responses)
Fetches information (e.g.
|
protected java.sql.Connection |
getConnection() |
protected javax.sql.DataSource |
getDataSourceFromJNDI(java.lang.String name) |
protected void |
handleView(View new_view,
View old_view,
boolean coord_changed) |
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) |
boolean |
isDynamic() |
boolean |
isInfoWriterRunning() |
protected void |
loadDriver() |
protected void |
readAll(java.sql.Connection connection,
java.util.List<Address> members,
java.lang.String clustername,
Responses rsps) |
protected void |
readAll(java.util.List<Address> members,
java.lang.String clustername,
Responses responses) |
protected void |
remove(java.lang.String clustername,
Address addr) |
protected void |
startInfoWriter() |
void |
stop()
This method is called on a
Channel.disconnect() . |
protected void |
stopInfoWriter() |
protected void |
verifyconfigurationParameters() |
void |
writeInfo() |
protected void |
writeOwnInformation(boolean overwrite)
Write my own UUID,logical name and physical address to a file
|
protected void |
writeToDB(PingData data,
java.lang.String clustername,
boolean overwrite) |
addDiscoveryResponseToCaches, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, dumpCache, findInitialMembersAsString, findMembers, forceDiscoveryResponses, forceDiscoveryResponses, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getTimeout, getView, getViewId, handleConnect, handleDisconnect, handleDiscoveryResponse, isCoord, isMergeRunning, marshal, numInitialMembers, numInitialMembers, providedUpServices, read, readPingData, resetStats, returnEntireCache, returnEntireCache, sendCacheInformation, sendDiscoveryResponse, serializeWithoutView, setForceSendingDiscoveryRsps, setNumInitialMembers, setTimeout, staggerTimeout, staggerTimeout, start, startCacheDissemination, timeout, timeout, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponses, write
accept, afterCreationHook, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, up
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 clear_sql
protected java.lang.String select_all_pingdata_sql
protected java.lang.String contains_sql
protected java.lang.String datasource_jndi_name
protected boolean register_shutdown_hook
protected int info_writer_max_writes_after_view
protected long info_writer_sleep_time
protected boolean clear_table_on_view_change
protected java.util.concurrent.Future<?> info_writer
public boolean isInfoWriterRunning()
public void writeInfo()
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 flushedpublic java.lang.Object down(Event evt)
Protocol
down_prot.down()
. In case of a GET_ADDRESS event (which tries to
retrieve the stack's address from one of the bottom layers), the layer may need to send
a new response event back up the stack using up_prot.up()
.public void findMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)
Discovery
Responses
object. If Discovery.async_discovery
is true, this method will be called
in a separate thread, otherwise the caller's thread will be used.findMembers
in class Discovery
members
- A list of logical addresses (typically UUID
s). If null, then information
for all members is fetchedinitial_discovery
- Set to true if this is for the initial membership discovery. Some protocols (e.g.
file based ones) may return only the information for the coordinator(s).responses
- The list to which responses should be addedprotected void writeOwnInformation(boolean overwrite)
protected void writeToDB(PingData data, java.lang.String clustername, boolean overwrite)
protected boolean contains(java.lang.String cluster_name, Address addr)
protected void remove(java.lang.String clustername, Address addr)
protected void readAll(java.util.List<Address> members, java.lang.String clustername, Responses responses)
protected void readAll(java.sql.Connection connection, java.util.List<Address> members, java.lang.String clustername, Responses rsps) throws java.sql.SQLException
java.sql.SQLException
protected void attemptSchemaInitialization()
protected void loadDriver()
protected java.sql.Connection getConnection()
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 void clearTable()
protected void closeConnection(java.sql.Connection connection)
protected javax.sql.DataSource getDataSourceFromJNDI(java.lang.String name)
protected void verifyconfigurationParameters()
protected void startInfoWriter()
protected void stopInfoWriter()
Copyright © 1998-2020 Red Hat. All Rights Reserved.