Class DistributedSQLCounter
java.lang.Object
org.apache.hadoop.hdfs.server.federation.router.security.token.DistributedSQLCounter
Distributed counter that relies on a SQL database to synchronize
between multiple clients. This expects a table with a single int field
to exist in the database. One record must exist on the table at all times,
representing the last used value reserved by a client.
-
Constructor Summary
ConstructorsConstructorDescriptionDistributedSQLCounter(String field, String table, SQLConnectionFactory connectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionintincrementCounterValue(int amount) Increments the counter by the given amount and returns the previous counter value.intObtains the value of the counter.voidupdateCounterValue(int value) Sets the counter to the given value.voidupdateCounterValue(int value, Connection connection) Sets the counter to the given value.
-
Constructor Details
-
DistributedSQLCounter
-
-
Method Details
-
selectCounterValue
Obtains the value of the counter.- Returns:
- counter value.
- Throws:
SQLException- if querying the database fails.
-
updateCounterValue
Sets the counter to the given value.- Parameters:
value- Value to assign to counter.- Throws:
SQLException- if querying the database fails.
-
updateCounterValue
Sets the counter to the given value.- Parameters:
value- Value to assign to counter.connection- Connection to database hosting the counter table.- Throws:
SQLException- if querying the database fails.
-
incrementCounterValue
Increments the counter by the given amount and returns the previous counter value.- Parameters:
amount- Amount to increase the counter.- Returns:
- Previous counter value.
- Throws:
SQLException- if querying the database fails.
-