Package org.keycloak.jgroups.protocol
Class KEYCLOAK_JDBC_PING2
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Discovery
org.jgroups.protocols.FILE_PING
org.jgroups.protocols.JDBC_PING2
org.keycloak.jgroups.protocol.KEYCLOAK_JDBC_PING2
- All Implemented Interfaces:
org.jgroups.Lifecycle
public class KEYCLOAK_JDBC_PING2
extends org.jgroups.protocols.JDBC_PING2
Enhanced JDBC_PING2 to handle entries transactionally.
Workaround for issue JGRP-2870
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jgroups.protocols.FILE_PING
org.jgroups.protocols.FILE_PING.InfoWriterNested classes/interfaces inherited from class org.jgroups.protocols.Discovery
org.jgroups.protocols.Discovery.DiscoveryCacheDisseminationTask -
Field Summary
Fields inherited from class org.jgroups.protocols.JDBC_PING2
call_insert_sp, clear_sql, connection_driver, connection_password, connection_url, connection_username, dataSource, datasource_injecter_class, datasource_jndi_name, delete_single_sql, initialize_sql, insert_single_sql, insert_sp, lock, select_all_pingdata_sqlFields 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 TypeMethodDescription<T extends org.jgroups.stack.Protocol>
Taddr(org.jgroups.Address addr) protected voidprotected voiddelete(Connection conn, String clustername, org.jgroups.Address addressToDelete) voidfindMembers(List<org.jgroups.Address> members, boolean initial_discovery, org.jgroups.util.Responses responses) protected Connectionprotected voidhandleView(org.jgroups.View new_view, org.jgroups.View old_view, boolean coord_changed) Detects a network partition and decides if the node belongs to the winning partition.protected voidinsert(Connection connection, org.jgroups.protocols.PingData data, String clustername) booleanprotected voidprotected voidprotected void<T extends org.jgroups.stack.Protocol>
TsetAddress(org.jgroups.Address addr) voidprotected voidMethods inherited from class org.jgroups.protocols.JDBC_PING2
assertNonNull, callInsertStoredProcedure, clearTable, createInsertStoredProcedure, createRootDir, createSchema, dump, getCallInsertSp, getClearSql, getConnectionDriver, getConnectionPassword, getConnectionUrl, getConnectionUsername, getDataSource, getDataSourceFromJNDI, getDatasourceInjecterClass, getDatasourceJndiName, getDeleteSingleSql, getInitializeSql, getInsertSingleSql, getInsertSp, getSelectAllPingdataSql, init, injectDataSource, main, prepare, readAll, readFromDB, remove, setCallInsertSp, setClearSql, setConnectionDriver, setConnectionPassword, setConnectionUrl, setConnectionUsername, setDataSource, setDatasourceInjecterClass, setDatasourceJndiName, setDeleteSingleSql, setInitializeSql, setInsertSingleSql, setInsertSp, setSelectAllPingdataSql, writeMethods inherited from class org.jgroups.protocols.FILE_PING
addressToFilename, deleteFile, down, getInfoWriterMaxWritesAfterView, getInfoWriterSleepTime, getLocation, isDynamic, 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, 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, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Constructor Details
-
KEYCLOAK_JDBC_PING2
public KEYCLOAK_JDBC_PING2()
-
-
Method Details
-
handleView
protected void handleView(org.jgroups.View new_view, org.jgroups.View old_view, boolean coord_changed) - Overrides:
handleViewin classorg.jgroups.protocols.FILE_PING
-
removeAll
- Overrides:
removeAllin classorg.jgroups.protocols.JDBC_PING2
-
learnExistingAddresses
protected void learnExistingAddresses() -
isInfoWriterRunning
public boolean isInfoWriterRunning()- Overrides:
isInfoWriterRunningin classorg.jgroups.protocols.FILE_PING
-
findMembers
public void findMembers(List<org.jgroups.Address> members, boolean initial_discovery, org.jgroups.util.Responses responses) - Overrides:
findMembersin classorg.jgroups.protocols.FILE_PING
-
writeToDB
protected void writeToDB(org.jgroups.protocols.PingData data, String clustername) throws SQLException - Overrides:
writeToDBin classorg.jgroups.protocols.JDBC_PING2- Throws:
SQLException
-
addr
public <T extends org.jgroups.stack.Protocol> T addr(org.jgroups.Address addr) - Overrides:
addrin classorg.jgroups.stack.Protocol
-
setAddress
public <T extends org.jgroups.stack.Protocol> T setAddress(org.jgroups.Address addr) - Overrides:
setAddressin classorg.jgroups.stack.Protocol
-
delete
protected void delete(Connection conn, String clustername, org.jgroups.Address addressToDelete) throws SQLException - Overrides:
deletein classorg.jgroups.protocols.JDBC_PING2- Throws:
SQLException
-
delete
- Overrides:
deletein classorg.jgroups.protocols.JDBC_PING2- Throws:
SQLException
-
insert
protected void insert(Connection connection, org.jgroups.protocols.PingData data, String clustername) throws SQLException - Overrides:
insertin classorg.jgroups.protocols.JDBC_PING2- Throws:
SQLException
-
loadDriver
protected void loadDriver()- Overrides:
loadDriverin classorg.jgroups.protocols.JDBC_PING2
-
getConnection
- Overrides:
getConnectionin classorg.jgroups.protocols.JDBC_PING2
-
setJpaConnectionProviderFactory
-
healthStatus
Detects a network partition and decides if the node belongs to the winning partition.The algorithm performs the following steps
- Reads the data from the database
- If an error occurs fetching the data, it returns
KEYCLOAK_JDBC_PING2.HealthStatus.ERROR - Filters out non coordinator members
- If no coordinator is found, it return
KEYCLOAK_JDBC_PING2.HealthStatus.NO_COORDINATOR - If multiple coordinators are found, it compares them and uses the coordinator with the lowest
UUID - Finally, it compares if the coordinator is the same as the current view coordinator. If so, it returns
KEYCLOAK_JDBC_PING2.HealthStatus.HEALTHY, otherwiseKEYCLOAK_JDBC_PING2.HealthStatus.UNHEALTHY
- Returns:
- The
KEYCLOAK_JDBC_PING2.HealthStatus. - See Also:
-