Package org.jgroups.protocols
Class JDBC_PING
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Discovery
org.jgroups.protocols.FILE_PING
org.jgroups.protocols.JDBC_PING
- All Implemented Interfaces:
Lifecycle
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.
- Since:
- 2.12
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgroups.protocols.FILE_PING
FILE_PING.InfoWriterNested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.DiscoveryCacheDisseminationTask -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected DataSourceprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected StringFields inherited from class org.jgroups.protocols.FILE_PING
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, write_data_on_find, writesFields inherited from class org.jgroups.protocols.Discovery
async_discovery, async_discovery_use_separate_thread_per_request, break_on_coord_rsp, cluster_name, current_coord, discovery_req_futures, discovery_rsp_callback, discovery_rsp_expiry_time, is_coord, is_leaving, is_server, max_members_in_discovery_request, max_rank_to_reply, num_discovery_requests, num_discovery_runs, ping_responses, return_entire_cache, send_cache_on_join, sends_can_block, stagger_timeout, timer, transport, transport_supports_multicasting, use_disk_cache, view, WHITESPACEFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidassertNonNull(String... strings) protected voidprotected voidclearTable(String clustername) protected voidcloseConnection(Connection connection) protected booleanprotected voidprotected voidprotected voiddelete(Connection connection, String clustername, String addressToDelete) protected Connectionprotected DataSourcegetDataSourceFromJNDI(String name) voidinit()Called after a protocol has been created and before the protocol is started.protected DataSourceinjectDataSource(String ds_class) protected voidinsert(Connection connection, PingData data, String clustername, String address) protected voidstatic voidprotected static final PreparedStatementprepareStatement(Connection connection, String sql, int resultSetType, int resultSetConcurrency) protected voidprotected voidprotected voidprotected voidRemoves all files for the given cluster nameprotected voidprotected voidprotected voidMethods inherited from class org.jgroups.protocols.FILE_PING
addressToFilename, deleteFile, down, findMembers, getInfoWriterMaxWritesAfterView, getInfoWriterSleepTime, getLocation, handleView, isDynamic, isInfoWriterRunning, read, read, registerShutdownHook, registerShutdownHook, removeAllDataOnViewChange, removeAllDataOnViewChange, removeOldCoordsOnViewChange, removeOldCoordsOnViewChange, resetStats, setInfoWriterMaxWritesAfterView, setInfoWriterSleepTime, setLocation, startInfoWriter, stop, stopInfoWriter, updateStoreOnViewChange, updateStoreOnViewChange, write, writeAll, writeAll, writeDataOnFind, writeDataOnFind, writeInfoMethods inherited from class org.jgroups.protocols.Discovery
addDiscoveryResponseToCaches, addResponse, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, callFindMembersInAllDiscoveryProtocols, clearRequestFutures, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, dumpCache, findInitialMembersAsString, findMembers, findTopmostDiscoveryProtocol, getClusterName, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getView, getViewId, handle, handleConnect, handleDisconnect, handleDiscoveryResponse, handleDiscoveryResponse, isCoord, isMergeRunning, marshal, marshal, marshal, print, providedUpServices, readPingData, returnEntireCache, returnEntireCache, sendCacheInformation, sendCacheOnJoin, sendCacheOnJoin, sendDiscoveryResponse, sendDiscoveryResponse, serializeWithoutView, setClusterName, staggerTimeout, staggerTimeout, start, startCacheDissemination, up, up, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponsesMethods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Field Details
-
connection_url
-
connection_username
-
connection_password
-
connection_driver
-
initialize_sql
-
insert_single_sql
-
delete_single_sql
-
clear_sql
-
select_all_pingdata_sql
-
contains_sql
-
datasource_jndi_name
-
datasource_injecter_class
-
dataSource
-
-
Constructor Details
-
JDBC_PING
public JDBC_PING()
-
-
Method Details
-
createRootDir
protected void createRootDir()- Overrides:
createRootDirin classFILE_PING
-
setDataSource
-
getDataSource
-
getConnectionUrl
-
setConnectionUrl
-
getConnectionUsername
-
setConnectionUsername
-
getConnectionPassword
-
setConnectionPassword
-
getConnectionDriver
-
setConnectionDriver
-
getInitializeSql
-
setInitializeSql
-
getInsertSingleSql
-
setInsertSingleSql
-
getDeleteSingleSql
-
setDeleteSingleSql
-
getClearSql
-
setClearSql
-
getSelectAllPingdataSql
-
setSelectAllPingdataSql
-
getContainsSql
-
setContainsSql
-
getDatasourceJndiName
-
setDatasourceJndiName
-
getDatasourceInjecterClass
-
setDatasourceInjecterClass
-
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent. -
write
-
writeToDB
-
contains
-
remove
-
removeAll
Description copied from class:FILE_PINGRemoves all files for the given cluster name -
readAll
-
prepareStatement
protected static final PreparedStatement prepareStatement(Connection connection, String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Throws:
SQLException
-
readAll
protected void readAll(Connection connection, List<Address> members, String clustername, Responses rsps) throws SQLException - Throws:
SQLException
-
attemptSchemaInitialization
protected void attemptSchemaInitialization() -
loadDriver
protected void loadDriver() -
injectDataSource
- Throws:
Exception
-
getConnection
-
insert
protected void insert(Connection connection, PingData data, String clustername, String address) throws SQLException - Throws:
SQLException
-
delete
protected void delete(Connection connection, String clustername, String addressToDelete) throws SQLException - Throws:
SQLException
-
delete
- Throws:
SQLException
-
clearTable
-
closeConnection
-
getDataSourceFromJNDI
-
verifyConfigurationParameters
protected void verifyConfigurationParameters() -
assertNonNull
-
main
- Throws:
ClassNotFoundException
-