org.jgroups.protocols
Class JDBC_PING

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.Discovery
          extended by org.jgroups.protocols.FILE_PING
              extended by org.jgroups.protocols.JDBC_PING

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.

Since:
2.12
Author:
Sanne Grinovero

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jgroups.protocols.FILE_PING
FILE_PING.WriterTask
 
Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.Responses
 
Field Summary
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
           
 
Fields inherited from class org.jgroups.protocols.FILE_PING
filter, interval, location, root_dir, SUFFIX
 
Fields inherited from class org.jgroups.protocols.Discovery
break_on_coord_rsp, current_coord, force_sending_discovery_rsps, group_addr, is_coord, is_leaving, is_server, local_addr, members, num_discovery_requests, num_initial_members, num_initial_srv_members, ping_responses, return_entire_cache, stagger_timeout, timeout, timer, use_disk_cache, view
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
JDBC_PING()
           
 
Method Summary
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  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)
           
 void stop()
          This method is called on a Channel.disconnect().
protected  void verifyconfigurationParameters()
           
protected  void writeToFile(PingData data, java.lang.String clustername)
           
 
Methods inherited from class org.jgroups.protocols.FILE_PING
addressAsString, down, fetchClusterMembers, handleView, isDynamic, sendDiscoveryRequestsInParallel, start
 
Methods inherited from class org.jgroups.protocols.Discovery
deserialize, discoveryRequestReceived, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembersAsString, findMembers, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getTimeout, getView, getViewId, handleConnect, handleDisconnect, isMergeRunning, providedUpServices, resetStats, sendDiscoveryRequest, sendDiscoveryResponse, sendMcastDiscoveryRequest, serializeWithoutView, setForceSendingDiscoveryRsps, setNumInitialMembers, setTimeout, up
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection_url

protected java.lang.String connection_url

connection_username

protected java.lang.String connection_username

connection_password

protected java.lang.String connection_password

connection_driver

protected java.lang.String connection_driver

initialize_sql

protected java.lang.String initialize_sql

insert_single_sql

protected java.lang.String insert_single_sql

delete_single_sql

protected java.lang.String delete_single_sql

select_all_pingdata_sql

protected java.lang.String select_all_pingdata_sql

datasource_jndi_name

protected java.lang.String datasource_jndi_name
Constructor Detail

JDBC_PING

public JDBC_PING()
Method Detail

init

public void init()
          throws java.lang.Exception
Description copied from class: Protocol
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.

Overrides:
init in class FILE_PING
Throws:
java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

stop

public void stop()
Description copied from class: Protocol
This method is called on a 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 flushed

Overrides:
stop in class FILE_PING

attemptSchemaInitialization

protected void attemptSchemaInitialization()

loadDriver

protected void loadDriver()

getConnection

protected java.sql.Connection getConnection()

createRootDir

protected void createRootDir()
Overrides:
createRootDir in class FILE_PING

remove

protected void remove(java.lang.String clustername,
                      Address addr)
Overrides:
remove in class FILE_PING

readAll

protected java.util.List<PingData> readAll(java.lang.String clustername)
Description copied from class: FILE_PING
Reads all information from the given directory under clustername

Overrides:
readAll in class FILE_PING
Returns:

readAll

protected java.util.List<PingData> readAll(java.sql.Connection connection,
                                           java.lang.String clustername)
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

writeToFile

protected void writeToFile(PingData data,
                           java.lang.String clustername)
Overrides:
writeToFile in class FILE_PING

insert

protected void insert(java.sql.Connection connection,
                      PingData data,
                      java.lang.String clustername,
                      java.lang.String address)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

delete

protected void delete(java.sql.Connection connection,
                      java.lang.String clustername,
                      java.lang.String addressToDelete)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

delete

protected void delete(java.lang.String clustername,
                      java.lang.String addressToDelete)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

deleteSelf

protected void deleteSelf()
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

closeConnection

protected void closeConnection(java.sql.Connection connection)

getDataSourceFromJNDI

protected javax.sql.DataSource getDataSourceFromJNDI(java.lang.String name)

verifyconfigurationParameters

protected void verifyconfigurationParameters()


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.