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.InfoWriter
Discovery.DiscoveryCacheDisseminationTask
Modifier and Type | Field and Description |
---|---|
protected String |
clear_sql |
protected String |
connection_driver |
protected String |
connection_password |
protected String |
connection_url |
protected String |
connection_username |
protected String |
contains_sql |
protected DataSource |
dataSource |
protected String |
datasource_jndi_name |
protected String |
delete_single_sql |
protected String |
initialize_sql |
protected String |
insert_single_sql |
protected String |
select_all_pingdata_sql |
filter, info_writer, info_writer_max_writes_after_view, info_writer_sleep_time, location, reads, regexp, register_shutdown_hook, remove_all_data_on_view_change, remove_old_coords_on_view_change, root_dir, SUFFIX, update_store_on_view_change, writes
async_discovery, async_discovery_use_separate_thread_per_request, break_on_coord_rsp, cluster_name, current_coord, discovery_rsp_expiry_time, is_coord, is_leaving, is_server, local_addr, max_members_in_discovery_request, max_rank_to_reply, num_discovery_requests, ping_responses, return_entire_cache, send_cache_on_join, sends_can_block, stagger_timeout, timer, transport_supports_multicasting, use_disk_cache, use_ip_addrs, view, WHITESPACE
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
Constructor and Description |
---|
JDBC_PING() |
Modifier and Type | Method and Description |
---|---|
protected void |
attemptSchemaInitialization() |
protected void |
clearTable(String clustername) |
protected void |
closeConnection(Connection connection) |
protected boolean |
contains(String cluster_name,
Address addr) |
protected void |
createRootDir() |
protected void |
delete(Connection connection,
String clustername,
String addressToDelete) |
protected void |
delete(String clustername,
String addressToDelete) |
protected Connection |
getConnection() |
protected DataSource |
getDataSourceFromJNDI(String name) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected void |
insert(Connection connection,
PingData data,
String clustername,
String address) |
protected void |
loadDriver() |
static void |
main(String[] args) |
protected static PreparedStatement |
prepareStatement(Connection connection,
String sql,
int resultSetType,
int resultSetConcurrency) |
protected void |
readAll(Connection connection,
List<Address> members,
String clustername,
Responses rsps) |
protected void |
readAll(List<Address> members,
String clustername,
Responses responses) |
protected void |
remove(String clustername,
Address addr) |
protected void |
removeAll(String clustername)
Removes all files for the given cluster name
|
void |
setDataSource(DataSource dataSource) |
void |
stop()
This method is called on a
JChannel.disconnect() . |
protected void |
verifyConfigurationParameters() |
protected void |
write(List<PingData> list,
String clustername) |
protected void |
writeToDB(PingData data,
String clustername,
boolean overwrite)
Contrary to the superclass' method, we only write our own address
|
addressToFilename, deleteFile, down, findMembers, handleView, isDynamic, isInfoWriterRunning, read, read, resetStats, startInfoWriter, stopInfoWriter, write, writeAll, writeAll, writeInfo
addDiscoveryResponseToCaches, addResponse, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, dumpCache, findInitialMembersAsString, findMembers, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getView, getViewId, handleConnect, handleDisconnect, handleDiscoveryResponse, isCoord, isMergeRunning, marshal, providedUpServices, readPingData, returnEntireCache, returnEntireCache, sendCacheInformation, sendDiscoveryResponse, serializeWithoutView, staggerTimeout, staggerTimeout, start, startCacheDissemination, up, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponses
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up
protected String connection_url
protected String connection_username
protected String connection_password
protected String connection_driver
protected String initialize_sql
protected String insert_single_sql
protected String delete_single_sql
protected String clear_sql
protected String select_all_pingdata_sql
protected String contains_sql
protected String datasource_jndi_name
protected DataSource dataSource
protected void createRootDir()
createRootDir
in class FILE_PING
public void setDataSource(DataSource dataSource)
public void init() throws Exception
Protocol
public void stop()
Protocol
JChannel.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 writeToDB(PingData data, String clustername, boolean overwrite)
protected void removeAll(String clustername)
FILE_PING
protected static final PreparedStatement prepareStatement(Connection connection, String sql, int resultSetType, int resultSetConcurrency) throws SQLException
SQLException
protected void readAll(Connection connection, List<Address> members, String clustername, Responses rsps) throws SQLException
SQLException
protected void attemptSchemaInitialization()
protected void loadDriver()
protected Connection getConnection()
protected void insert(Connection connection, PingData data, String clustername, String address) throws SQLException
SQLException
protected void delete(Connection connection, String clustername, String addressToDelete) throws SQLException
SQLException
protected void delete(String clustername, String addressToDelete) throws SQLException
SQLException
protected void clearTable(String clustername)
protected void closeConnection(Connection connection)
protected DataSource getDataSourceFromJNDI(String name)
protected void verifyConfigurationParameters()
public static void main(String[] args) throws ClassNotFoundException
ClassNotFoundException
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.