com.continuent.tungsten.common.cluster.resource
Class DataSource

java.lang.Object
  extended by com.continuent.tungsten.common.cluster.resource.Resource
      extended by com.continuent.tungsten.common.cluster.resource.DataSource
All Implemented Interfaces:
java.io.Serializable

public class DataSource
extends Resource
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
static java.lang.String ACTIVE_CONNECTION_COUNT
           
static java.lang.String ALERT_MESSAGE
           
static java.lang.String ALERT_STATUS
           
static java.lang.String ALERT_TIME
           
static java.lang.String APPLIED_LATENCY
           
static java.lang.String CLUSTERNAME
           
static java.lang.String CONNECTIONS_CREATED_COUNT
           
static double DEFAULT_APPLIED_LATENCY
           
static java.lang.String DRIVER
           
static java.lang.String HIGHWATER
           
static java.lang.String HOST
           
static java.lang.String ISAVAILABLE
           
static java.lang.String ISCOMPOSITE
           
static java.lang.String ISWITNESS
           
static java.lang.String JDBC_URL_START
           
static java.lang.String LASTERROR
           
static java.lang.String LASTSHUNREASON
           
static java.lang.String MASTER_CONNECT_URI
           
static java.lang.String NAME
           
static java.lang.String PRECEDENCE
           
static java.lang.String ROLE
           
static java.lang.String STATE
           
static java.lang.String TYPE
           
static java.lang.String URL
           
static java.lang.String VENDOR
           
static java.lang.String VIPADDRESS
           
static java.lang.String VIPINTERFACE
           
static java.lang.String VIPISBOUND
           
 
Fields inherited from class com.continuent.tungsten.common.cluster.resource.Resource
childType, compositeMember, description, isContainer, isExecutable, name, type
 
Constructor Summary
DataSource()
          Creates a new DataSource object
DataSource(java.util.Map<java.lang.String,java.lang.String> dsProperties)
          Creates a new DataSource object
DataSource(java.lang.String key, java.lang.String clusterName, java.lang.String host)
           
DataSource(TungstenProperties props)
           
 
Method Summary
 void addConnection(DatabaseConnection conn)
           
static DataSource copy(DataSource ds)
           
static TungstenProperties createFromReplicatorStatus(TungstenProperties replicatorProps)
           
static TungstenProperties createWitnessFromMemberHeartbeat(TungstenProperties memberHeartbeatProps)
           
 void decrementActiveConnections()
           
 void disable()
          Prevent the driver from pDaterocessing new connection requests.
static int extractPortFromJDBCUrl(java.lang.String url)
           
 long getActiveConnectionCount()
           
 java.util.Set<DatabaseConnection> getActiveConnections()
          Provides a reference to the synchronized set of active connections.
 java.lang.String getAlertMessage()
           
 DataSourceAlertStatus getAlertStatus()
           
 long getAlertTime()
           
 double getAppliedLatency()
          Format a datasource for display
 long getCallableStatementsCreated()
          Returns the number of JDBC CallableStatement instances created.
 long getConnectionsCreated()
          Returns the number of connections created on this datasource.
 java.lang.String getDataServiceName()
          Returns the dataServiceName value.
 DataSourceRole getDataSourceRole()
           
 java.lang.String getDriver()
           
 java.util.concurrent.atomic.AtomicInteger getEnabled()
           
 HighWaterResource getHighWater()
           
 java.lang.String getHost()
          Returns the host value.
 boolean getIsAvailable()
           
 java.lang.String getLastError()
           
 java.lang.String getLastShunReason()
           
 java.util.Date getLastUpdate()
          Gives the last time this data source received an update
 java.lang.String getMasterConnectUri()
           
 int getPrecedence()
           
 long getPreparedStatementsCreated()
          Returns the number of JDBC PreparedStatement instances created.
 java.lang.String getRole()
           
 Sequence getSequence()
          Returns the sequence value.
 ResourceState getState()
           
 long getStatementsCreated()
          Returns the number of JDBC Statement instances created.
 java.util.Date getUpdateTimestamp()
           
 java.lang.String getUrl()
           
 java.lang.String getVendor()
           
 java.lang.String getVipAddress()
           
 java.lang.String getVipInterface()
           
 boolean getVipIsBound()
           
 void incrementActiveConnections()
           
 void incrementCallableStatementsCreated()
           
 void incrementConnectionsCreated()
           
 void incrementPreparedStatementsCreated()
           
 void incrementStatementsCreated()
           
 boolean isAvailable()
           
 boolean isComposite()
           
 boolean isMaster()
           
 boolean isRelay()
           
 boolean isSlave()
           
 boolean isStandby()
          Returns the standby value.
 void removeConnection(DatabaseConnection conn)
           
 void set(java.util.Map<java.lang.String,java.lang.String> dsProperties)
           
 void setActiveConnectionCount(long activeConnectionCount)
          Set the activeConnectionCount for this data source from the count passed via a long
 void setAlert(DataSourceAlertStatus status, java.lang.String message)
           
 void setAlertMessage(java.lang.String alertMessage)
           
 void setAlertStatus(DataSourceAlertStatus alertStatus)
           
 void setAlertTime(long alertTime)
           
 void setAppliedLatency(double appliedLatency)
          Sets the last seen latency of this data source
 void setComposite(boolean isComposite)
           
 void setConnectionsCreatedCount(long connectionsCreatedCount)
          Set the connectionsCreatedCount for this data source from the count passed via a long
 void setCritical(java.lang.String message)
           
 void setDataServiceName(java.lang.String dataServiceName)
          Sets the dataServiceName value.
 void setDataSourceRole(DataSourceRole role)
           
 void setDriver(java.lang.String driver)
           
 void setEnabled(java.util.concurrent.atomic.AtomicInteger enabled)
           
 void setFailed(java.lang.String error)
           
 void setHighWater(HighWaterResource highWater)
           
 void setHighWater(long epoch, java.lang.String eventId)
           
 void setHost(java.lang.String host)
          Sets the host value.
 void setIsAvailable(boolean isAvailable)
           
 void setIsComposite(boolean isComposite)
           
 void setLastError(java.lang.String lastError)
           
 void setLastShunReason(java.lang.String lastShunReason)
           
 void setMasterConnectUri(java.lang.String masterConnectUri)
           
 void setPrecedence(int precedence)
           
 void setRole(java.lang.String role)
           
 void setSequence(Sequence sequence)
          Sets the sequence value.
 void setShunned(java.lang.String reason)
           
 void setStandby(boolean isStandby)
          Sets the standby value.
 void setState(ResourceState state)
           
 void setUpdateTimestamp(java.util.Date updateTimestamp)
           
 void setUrl(java.lang.String url)
           
 void setVendor(java.lang.String vendor)
           
 void setVipAddress(java.lang.String vipAddress)
           
 void setVipInterface(java.lang.String vipInterface)
           
 void setVipIsBound(boolean vipIsBound)
           
 java.util.Map<java.lang.String,java.lang.String> toMap()
          TODO: toMap definition.
 TungstenProperties toProperties()
           
 java.lang.String toString()
          Format a datasource for display
 void update(DataSource ds)
          Update a given datasource with values from a different datasource
static TungstenProperties updateFromReplicatorStatus(TungstenProperties replicatorProps, TungstenProperties dsProps)
           
 
Methods inherited from class com.continuent.tungsten.common.cluster.resource.Resource
copyTo, describe, getChildType, getCompositeMember, getKey, getName, getType, isContainer, isExecutable, setChildType, setCompositeMember, setContainer, setExecutable, setName, setType, toJSON
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

CLUSTERNAME

public static final java.lang.String CLUSTERNAME
See Also:
Constant Field Values

PRECEDENCE

public static final java.lang.String PRECEDENCE
See Also:
Constant Field Values

ISAVAILABLE

public static final java.lang.String ISAVAILABLE
See Also:
Constant Field Values

STATE

public static final java.lang.String STATE
See Also:
Constant Field Values

ISCOMPOSITE

public static final java.lang.String ISCOMPOSITE
See Also:
Constant Field Values

ISWITNESS

public static final java.lang.String ISWITNESS
See Also:
Constant Field Values

ALERT_STATUS

public static final java.lang.String ALERT_STATUS
See Also:
Constant Field Values

ALERT_MESSAGE

public static final java.lang.String ALERT_MESSAGE
See Also:
Constant Field Values

ALERT_TIME

public static final java.lang.String ALERT_TIME
See Also:
Constant Field Values

APPLIED_LATENCY

public static final java.lang.String APPLIED_LATENCY
See Also:
Constant Field Values

HOST

public static final java.lang.String HOST
See Also:
Constant Field Values

ROLE

public static final java.lang.String ROLE
See Also:
Constant Field Values

VENDOR

public static final java.lang.String VENDOR
See Also:
Constant Field Values

DRIVER

public static final java.lang.String DRIVER
See Also:
Constant Field Values

URL

public static final java.lang.String URL
See Also:
Constant Field Values

LASTERROR

public static final java.lang.String LASTERROR
See Also:
Constant Field Values

LASTSHUNREASON

public static final java.lang.String LASTSHUNREASON
See Also:
Constant Field Values

HIGHWATER

public static final java.lang.String HIGHWATER
See Also:
Constant Field Values

VIPINTERFACE

public static final java.lang.String VIPINTERFACE
See Also:
Constant Field Values

VIPADDRESS

public static final java.lang.String VIPADDRESS
See Also:
Constant Field Values

VIPISBOUND

public static final java.lang.String VIPISBOUND
See Also:
Constant Field Values

ACTIVE_CONNECTION_COUNT

public static final java.lang.String ACTIVE_CONNECTION_COUNT
See Also:
Constant Field Values

CONNECTIONS_CREATED_COUNT

public static final java.lang.String CONNECTIONS_CREATED_COUNT
See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

MASTER_CONNECT_URI

public static final java.lang.String MASTER_CONNECT_URI
See Also:
Constant Field Values

DEFAULT_APPLIED_LATENCY

public static final double DEFAULT_APPLIED_LATENCY
See Also:
Constant Field Values

JDBC_URL_START

public static final java.lang.String JDBC_URL_START
See Also:
Constant Field Values
Constructor Detail

DataSource

public DataSource()
Creates a new DataSource object


DataSource

public DataSource(TungstenProperties props)

DataSource

public DataSource(java.lang.String key,
                  java.lang.String clusterName,
                  java.lang.String host)

DataSource

public DataSource(java.util.Map<java.lang.String,java.lang.String> dsProperties)
Creates a new DataSource object

Parameters:
dsProperties -
Method Detail

addConnection

public void addConnection(DatabaseConnection conn)

removeConnection

public void removeConnection(DatabaseConnection conn)

getActiveConnectionCount

public long getActiveConnectionCount()

getActiveConnections

public java.util.Set<DatabaseConnection> getActiveConnections()
Provides a reference to the synchronized set of active connections. Any iterator operation on this set MUST be synchronized on the set object

Returns:
the active connections set

updateFromReplicatorStatus

public static TungstenProperties updateFromReplicatorStatus(TungstenProperties replicatorProps,
                                                            TungstenProperties dsProps)

createFromReplicatorStatus

public static TungstenProperties createFromReplicatorStatus(TungstenProperties replicatorProps)

createWitnessFromMemberHeartbeat

public static TungstenProperties createWitnessFromMemberHeartbeat(TungstenProperties memberHeartbeatProps)

getDriver

public java.lang.String getDriver()

setDriver

public void setDriver(java.lang.String driver)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getRole

public java.lang.String getRole()

getDataSourceRole

public DataSourceRole getDataSourceRole()

setRole

public void setRole(java.lang.String role)

setDataSourceRole

public void setDataSourceRole(DataSourceRole role)

getMasterConnectUri

public java.lang.String getMasterConnectUri()

setMasterConnectUri

public void setMasterConnectUri(java.lang.String masterConnectUri)

getPrecedence

public int getPrecedence()

setPrecedence

public void setPrecedence(int precedence)

getVendor

public java.lang.String getVendor()

setVendor

public void setVendor(java.lang.String vendor)

isAvailable

public boolean isAvailable()
Returns:
the isAvailable

getIsAvailable

public boolean getIsAvailable()
Returns:
the isAvailable

setCritical

public void setCritical(java.lang.String message)

setIsAvailable

public void setIsAvailable(boolean isAvailable)
Parameters:
isAvailable - the isDateAvailable to set

disable

public void disable()
             throws java.lang.InterruptedException
Prevent the driver from pDaterocessing new connection requests. If the driver is disabled, it will either cause new connection requests to wait or will throw a SQLException.

Throws:
java.lang.InterruptedException

update

public void update(DataSource ds)
Update a given datasource with values from a different datasource

Parameters:
ds -

toProperties

public TungstenProperties toProperties()
Overrides:
toProperties in class Resource

toMap

public java.util.Map<java.lang.String,java.lang.String> toMap()
TODO: toMap definition.

Returns:
properties representing this datasource

set

public void set(java.util.Map<java.lang.String,java.lang.String> dsProperties)

getSequence

public Sequence getSequence()
Returns the sequence value.

Returns:
Returns the sequence.

incrementActiveConnections

public void incrementActiveConnections()

decrementActiveConnections

public void decrementActiveConnections()

getConnectionsCreated

public long getConnectionsCreated()
Returns the number of connections created on this datasource.


incrementConnectionsCreated

public void incrementConnectionsCreated()

getStatementsCreated

public long getStatementsCreated()
Returns the number of JDBC Statement instances created.


incrementStatementsCreated

public void incrementStatementsCreated()

getPreparedStatementsCreated

public long getPreparedStatementsCreated()
Returns the number of JDBC PreparedStatement instances created.


incrementPreparedStatementsCreated

public void incrementPreparedStatementsCreated()

getCallableStatementsCreated

public long getCallableStatementsCreated()
Returns the number of JDBC CallableStatement instances created.


incrementCallableStatementsCreated

public void incrementCallableStatementsCreated()

getDataServiceName

public java.lang.String getDataServiceName()
Returns the dataServiceName value.

Returns:
Returns the dataServiceName.

setDataServiceName

public void setDataServiceName(java.lang.String dataServiceName)
Sets the dataServiceName value.

Parameters:
dataServiceName - The dataServiceName to set.

getAppliedLatency

public double getAppliedLatency()
Format a datasource for display


setAppliedLatency

public void setAppliedLatency(double appliedLatency)
Sets the last seen latency of this data source

Parameters:
appliedLatency - update appliedLatency observed

toString

public java.lang.String toString()
Format a datasource for display

Overrides:
toString in class Resource

getLastUpdate

public java.util.Date getLastUpdate()
Gives the last time this data source received an update

Returns:
the last update time

setSequence

public void setSequence(Sequence sequence)
Sets the sequence value.

Parameters:
sequence - The sequence to set.

getHost

public java.lang.String getHost()
Returns the host value.

Returns:
Returns the host.

setHost

public void setHost(java.lang.String host)
Sets the host value.

Parameters:
host - The host to set.

getHighWater

public HighWaterResource getHighWater()

setHighWater

public void setHighWater(HighWaterResource highWater)

setHighWater

public void setHighWater(long epoch,
                         java.lang.String eventId)

getEnabled

public java.util.concurrent.atomic.AtomicInteger getEnabled()

setEnabled

public void setEnabled(java.util.concurrent.atomic.AtomicInteger enabled)

isMaster

public boolean isMaster()

isSlave

public boolean isSlave()

isRelay

public boolean isRelay()

getState

public ResourceState getState()

setState

public void setState(ResourceState state)

setFailed

public void setFailed(java.lang.String error)

setShunned

public void setShunned(java.lang.String reason)

getLastError

public java.lang.String getLastError()

setLastError

public void setLastError(java.lang.String lastError)

getLastShunReason

public java.lang.String getLastShunReason()

setLastShunReason

public void setLastShunReason(java.lang.String lastShunReason)

copy

public static DataSource copy(DataSource ds)

getVipInterface

public java.lang.String getVipInterface()

setVipInterface

public void setVipInterface(java.lang.String vipInterface)

getVipAddress

public java.lang.String getVipAddress()

setVipAddress

public void setVipAddress(java.lang.String vipAddress)

getVipIsBound

public boolean getVipIsBound()

setVipIsBound

public void setVipIsBound(boolean vipIsBound)

getUpdateTimestamp

public java.util.Date getUpdateTimestamp()

setUpdateTimestamp

public void setUpdateTimestamp(java.util.Date updateTimestamp)

getAlertStatus

public DataSourceAlertStatus getAlertStatus()

setAlertStatus

public void setAlertStatus(DataSourceAlertStatus alertStatus)

getAlertMessage

public java.lang.String getAlertMessage()

setAlertMessage

public void setAlertMessage(java.lang.String alertMessage)

setAlert

public void setAlert(DataSourceAlertStatus status,
                     java.lang.String message)

getAlertTime

public long getAlertTime()

setAlertTime

public void setAlertTime(long alertTime)

isComposite

public boolean isComposite()

setComposite

public void setComposite(boolean isComposite)

setIsComposite

public void setIsComposite(boolean isComposite)

isStandby

public boolean isStandby()
Returns the standby value.

Returns:
Returns the standby.

setStandby

public void setStandby(boolean isStandby)
Sets the standby value.


setActiveConnectionCount

public void setActiveConnectionCount(long activeConnectionCount)
Set the activeConnectionCount for this data source from the count passed via a long

Parameters:
activeConnectionCount -

setConnectionsCreatedCount

public void setConnectionsCreatedCount(long connectionsCreatedCount)
Set the connectionsCreatedCount for this data source from the count passed via a long

Parameters:
connectionsCreatedCount -

extractPortFromJDBCUrl

public static int extractPortFromJDBCUrl(java.lang.String url)
                                  throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException