Skip to content

Commit

Permalink
#72 upgrade to qulice 0.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Feb 23, 2016
1 parent a977b2e commit 9572854
Show file tree
Hide file tree
Showing 31 changed files with 142 additions and 60 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Expand Up @@ -35,7 +35,7 @@
<parent>
<groupId>com.jcabi</groupId>
<artifactId>jcabi</artifactId>
<version>1.21</version>
<version>1.22</version>
</parent>
<artifactId>jcabi-dynamo</artifactId>
<version>1.0-SNAPSHOT</version>
Expand Down Expand Up @@ -215,6 +215,7 @@
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.16.2</version>
<configuration>
<excludes>
<exclude>findbugs:.*</exclude>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Attributes.java
Expand Up @@ -59,6 +59,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/AwsFrame.java
Expand Up @@ -45,6 +45,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/AwsItem.java
Expand Up @@ -56,6 +56,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/AwsIterator.java
Expand Up @@ -58,6 +58,7 @@
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @checkstyle ClassDataAbstractionCoupling (500 lines)
* @since 0.1
*/
@Loggable(Loggable.DEBUG)
@ToString
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/AwsTable.java
Expand Up @@ -60,6 +60,7 @@
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @checkstyle ClassDataAbstractionCoupling (150 lines)
* @since 0.1
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down
28 changes: 19 additions & 9 deletions src/main/java/com/jcabi/dynamo/Conditions.java
Expand Up @@ -58,6 +58,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down Expand Up @@ -88,15 +89,7 @@ public Conditions() {
* @param map Map of them
*/
public Conditions(final Map<String, Condition> map) {
final ConcurrentMap<String, Condition> cnds =
new ConcurrentHashMap<String, Condition>(map.size());
for (final Map.Entry<String, Condition> entry : map.entrySet()) {
cnds.put(
String.format(Locale.ENGLISH, entry.getKey()),
entry.getValue()
);
}
this.conds = new ArrayMap<String, Condition>(cnds);
this.conds = Conditions.array(map);
}

/**
Expand Down Expand Up @@ -251,4 +244,21 @@ public void clear() {
);
}

/**
* Convert map to ArrayMap.
* @param map Map of them
* @return Array map
*/
private static ArrayMap<String, Condition> array(
final Map<String, Condition> map) {
final ConcurrentMap<String, Condition> cnds =
new ConcurrentHashMap<String, Condition>(map.size());
for (final Map.Entry<String, Condition> entry : map.entrySet()) {
cnds.put(
String.format(Locale.ENGLISH, entry.getKey()),
entry.getValue()
);
}
return new ArrayMap<String, Condition>(cnds);
}
}
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Credentials.java
Expand Up @@ -45,6 +45,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
public interface Credentials {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Dosage.java
Expand Up @@ -43,6 +43,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
public interface Dosage {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Frame.java
Expand Up @@ -54,6 +54,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
* @see Item
* @see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and Scan</a>
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Item.java
Expand Up @@ -45,6 +45,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
public interface Item {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/jcabi/dynamo/QueryValve.java
Expand Up @@ -58,6 +58,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@ToString
Expand Down Expand Up @@ -180,8 +181,8 @@ public Dosage fetch(final Credentials credentials, final String table,
* With consistent read.
* @param cnst Consistent read
* @return New query valve
* @since 0.12
* @see QueryRequest#withConsistentRead(Boolean)
* @since 0.12
* @checkstyle AvoidDuplicateLiterals (5 line)
*/
public QueryValve withConsistentRead(final boolean cnst) {
Expand All @@ -196,8 +197,8 @@ public QueryValve withConsistentRead(final boolean cnst) {
* With index name.
* @param idx Index name
* @return New query valve
* @since 0.10.2
* @see QueryRequest#withIndexName(String)
* @since 0.10.2
* @checkstyle AvoidDuplicateLiterals (5 line)
*/
public QueryValve withIndexName(final String idx) {
Expand All @@ -212,8 +213,8 @@ public QueryValve withIndexName(final String idx) {
* With attributes to select.
* @param slct Select to use
* @return New query valve
* @since 0.10.2
* @see QueryRequest#withSelect(Select)
* @since 0.10.2
* @checkstyle AvoidDuplicateLiterals (5 line)
*/
public QueryValve withSelect(final Select slct) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/Region.java
Expand Up @@ -56,6 +56,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
public interface Region {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcabi/dynamo/ScanValve.java
Expand Up @@ -57,6 +57,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
@ToString
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/jcabi/dynamo/Table.java
Expand Up @@ -53,6 +53,7 @@
*
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@Immutable
public interface Table {
Expand All @@ -65,8 +66,8 @@ public interface Table {
*
* @param attributes Attributes to save
* @return Item just created
* @see Attributes
* @throws IOException In case of DynamoDB failure
* @see Attributes
*/
Item put(Map<String, AttributeValue> attributes) throws IOException;

Expand All @@ -93,8 +94,8 @@ public interface Table {
* <p>It is recommended to use {@link Attributes} supplementary class,
* instead of a raw {@link Map}.
* @param attributes Attributes containing item key and value
* @see Attributes
* @throws IOException In case of DynamoDB failure
* @see Attributes
*/
void delete(Map<String, AttributeValue> attributes) throws IOException;

Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/jcabi/dynamo/Throughput.java
Expand Up @@ -61,20 +61,19 @@ public void adjust() {
.aws()
.updateTable(
this.table.name(),
this.suitableThroughput()
Throughput.suitableThroughput()
);
}

/**
* Decides which throughput value is the most suitable according to
* certain parameters of elasticity/scalability.
* @return Throughput settings.
* @todo #10 The exact algorithm for figuring out read and write
* capacities should be based on a CloudWatch metric accessed with
* credentials of this.table.region().aws().
*/
private ProvisionedThroughput suitableThroughput() {
/* @todo #10 The exact algorithm for figuring out read and write
* capacities should be based on a CloudWatch metric accessed with
* credentials of this.table.region().aws().
*/
private static ProvisionedThroughput suitableThroughput() {
return new ProvisionedThroughput(
(long) Tv.HUNDRED,
(long) Tv.HUNDRED
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/jcabi/dynamo/retry/ReTable.java
Expand Up @@ -95,11 +95,6 @@ public String name() {
return this.origin.name();
}

/**
* Delete item from aws table.
* @param attributes Attributes
* @throws IOException In case of DynamoDB failure
*/
@Override
@RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS)
public void delete(final Map<String, AttributeValue> attributes)
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/jcabi/dynamo/AttributesTest.java
Expand Up @@ -42,6 +42,7 @@
* Test case for {@link Attributes}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@SuppressWarnings("PMD.UseConcurrentHashMap")
public final class AttributesTest {
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/com/jcabi/dynamo/AwsIteratorITCase.java
Expand Up @@ -51,11 +51,12 @@ public final class AwsIteratorITCase {
@Test
public void iteratesItems() throws Exception {
final String name = RandomStringUtils.randomAlphabetic(Tv.EIGHT);
final Table tbl = new RegionMock().get(name).table(name);
final RegionMock mock = new RegionMock();
final Table tbl = mock.get(name).table(name);
tbl.put(
new Attributes()
.with(RegionMock.HASH, "test")
.with(RegionMock.RANGE, 1L)
.with(mock.hash(), "test")
.with(mock.range(), 1L)
);
MatcherAssert.assertThat(
tbl.frame(),
Expand All @@ -70,10 +71,11 @@ public void iteratesItems() throws Exception {
@Test
public void iteratesItemsAndDeletes() throws Exception {
final String name = RandomStringUtils.randomAlphabetic(Tv.EIGHT);
final Table tbl = new RegionMock().get(name).table(name);
final Attributes attrs = new Attributes().with(RegionMock.RANGE, 1L);
final RegionMock mock = new RegionMock();
final Table tbl = mock.get(name).table(name);
final Attributes attrs = new Attributes().with(mock.range(), 1L);
for (int idx = 0; idx < Tv.SIX; ++idx) {
tbl.put(attrs.with(RegionMock.HASH, String.format("i%d", idx)));
tbl.put(attrs.with(mock.hash(), String.format("i%d", idx)));
}
final Iterator<Item> items = tbl.frame().iterator();
int cnt = 0;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/jcabi/dynamo/AwsIteratorTest.java
Expand Up @@ -46,6 +46,7 @@
* Test case for {@link AwsIterator}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@SuppressWarnings("unchecked")
public final class AwsIteratorTest {
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/com/jcabi/dynamo/AwsTableTest.java
Expand Up @@ -49,6 +49,7 @@
* Test case for {@link AwsTable}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
* @checkstyle ClassDataAbstractionCoupling (500 lines)
*/
public final class AwsTableTest {
Expand Down Expand Up @@ -79,7 +80,7 @@ public void savesItemToDynamo() throws Exception {
Mockito.doReturn(
new DescribeTableResult().withTable(
new TableDescription().withKeySchema(
new KeySchemaElement().withAttributeName(KEY)
new KeySchemaElement().withAttributeName(AwsTableTest.KEY)
)
)
).when(aws).describeTable(Mockito.any(DescribeTableRequest.class));
Expand All @@ -95,7 +96,7 @@ public void savesItemToDynamo() throws Exception {
MockitoHamcrest.argThat(
Matchers.allOf(
Matchers.hasProperty(
TABLE_NAME,
AwsTableTest.TABLE_NAME,
Matchers.equalTo(name)
),
Matchers.hasProperty(
Expand Down Expand Up @@ -128,7 +129,7 @@ public void deletesItemFromDynamo() throws Exception {
Mockito.doReturn(
new DescribeTableResult().withTable(
new TableDescription().withKeySchema(
new KeySchemaElement().withAttributeName(KEY)
new KeySchemaElement().withAttributeName(AwsTableTest.KEY)
)
)
).when(aws).describeTable(Mockito.any(DescribeTableRequest.class));
Expand All @@ -144,11 +145,11 @@ public void deletesItemFromDynamo() throws Exception {
MockitoHamcrest.argThat(
Matchers.allOf(
Matchers.hasProperty(
TABLE_NAME,
AwsTableTest.TABLE_NAME,
Matchers.equalTo(name)
),
Matchers.hasProperty(
KEY,
AwsTableTest.KEY,
Matchers.hasEntry(
Matchers.equalTo(attr),
Matchers.equalTo(value)
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/jcabi/dynamo/ConditionsTest.java
Expand Up @@ -39,6 +39,7 @@
* Test case for {@link Conditions}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
@SuppressWarnings("PMD.UseConcurrentHashMap")
public final class ConditionsTest {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/jcabi/dynamo/CredentialsTest.java
Expand Up @@ -37,6 +37,7 @@
* Test case for {@link Credentials}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
public final class CredentialsTest {

Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/jcabi/dynamo/QueryValveTest.java
Expand Up @@ -47,6 +47,7 @@
* Test case for {@link QueryValve}.
* @author Yegor Bugayenko (yegor@tpc2.com)
* @version $Id$
* @since 0.1
*/
public final class QueryValveTest {

Expand Down

0 comments on commit 9572854

Please sign in to comment.