├── .gitignore
├── .settings
└── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.txt
├── changes.txt
├── pom.xml
├── troilus-core-java7
├── pom.xml
└── src
│ └── main
│ └── java
│ └── net
│ └── oneandone
│ └── troilus
│ ├── AbstractQuery.java
│ ├── BatchMutationQuery.java
│ ├── BeanMapper.java
│ ├── ColumnName.java
│ ├── ConstraintException.java
│ ├── Context.java
│ ├── Count.java
│ ├── CounterBatchMutationQuery.java
│ ├── CounterMutationQuery.java
│ ├── CounterMutationQueryData.java
│ ├── DBSession.java
│ ├── DataTypes.java
│ ├── DeleteQuery.java
│ ├── DeleteQueryDataImpl.java
│ ├── ExecutionSpec.java
│ ├── Field.java
│ ├── IfConditionException.java
│ ├── Immutables.java
│ ├── InsertQuery.java
│ ├── InterceptorRegistry.java
│ ├── Java7DaoImpl.java
│ ├── ListReadQuery.java
│ ├── ListenableFutures.java
│ ├── MetadataCatalog.java
│ ├── MutationQuery.java
│ ├── Optionals.java
│ ├── PropertiesSource.java
│ ├── ProtocolErrorException.java
│ ├── ReadQueryDataImpl.java
│ ├── RecordImpl.java
│ ├── RecordListImpl.java
│ ├── Result.java
│ ├── ResultAdapter.java
│ ├── ResultListPublisher.java
│ ├── ResultListSubscription.java
│ ├── SingleEntryResultListAdapter.java
│ ├── SingleReadQuery.java
│ ├── Tablename.java
│ ├── TooManyResultsException.java
│ ├── UDTValueMapper.java
│ ├── UpdateQuery.java
│ ├── WriteQuery.java
│ ├── WriteQueryDataImpl.java
│ ├── WriteWithCounterQuery.java
│ ├── interceptor
│ ├── ConstraintsInterceptor.java
│ ├── DeleteQueryData.java
│ ├── QueryInterceptor.java
│ └── SingleReadQueryData.java
│ └── java7
│ ├── BatchMutation.java
│ ├── Batchable.java
│ ├── BatchableWithTime.java
│ ├── CounterMutation.java
│ ├── Dao.java
│ ├── Deletion.java
│ ├── FetchingIterable.java
│ ├── FetchingIterator.java
│ ├── Insertion.java
│ ├── ListRead.java
│ ├── ListReadWithColumns.java
│ ├── ListReadWithUnit.java
│ ├── Mutation.java
│ ├── Query.java
│ ├── Record.java
│ ├── ResultList.java
│ ├── SingleRead.java
│ ├── SingleReadWithColumns.java
│ ├── SingleReadWithUnit.java
│ ├── Update.java
│ ├── UpdateWithUnit.java
│ ├── UpdateWithUnitAndCounter.java
│ ├── WithCounter.java
│ ├── Write.java
│ ├── WriteWithCounter.java
│ └── interceptor
│ ├── CascadeOnDeleteInterceptor.java
│ ├── CascadeOnWriteInterceptor.java
│ ├── DeleteQueryRequestInterceptor.java
│ ├── ReadQueryData.java
│ ├── ReadQueryRequestInterceptor.java
│ ├── ReadQueryResponseInterceptor.java
│ ├── ResultListAdapter.java
│ ├── WriteQueryData.java
│ └── WriteQueryRequestInterceptor.java
└── troilus-core
├── .gitignore
├── .toDelete
├── pom.xml
└── src
├── main
└── java
│ └── net
│ └── oneandone
│ └── troilus
│ ├── AbstractQueryAdapter.java
│ ├── BatchMutation.java
│ ├── BatchMutationQueryAdapter.java
│ ├── Batchable.java
│ ├── BatchableWithTime.java
│ ├── CompletableFutures.java
│ ├── CounterBatchMutationQueryAdapter.java
│ ├── CounterMutation.java
│ ├── CounterMutationQueryAdapter.java
│ ├── Dao.java
│ ├── DaoImpl.java
│ ├── DeleteQueryAdapter.java
│ ├── Deletion.java
│ ├── FetchingIterable.java
│ ├── FetchingIterator.java
│ ├── InsertQueryAdapter.java
│ ├── Insertion.java
│ ├── ListRead.java
│ ├── ListReadQueryAdapter.java
│ ├── ListReadWithColumns.java
│ ├── ListReadWithUnit.java
│ ├── Mutation.java
│ ├── Mutations.java
│ ├── Query.java
│ ├── Record.java
│ ├── RecordAdapter.java
│ ├── RecordMappingPublisher.java
│ ├── ResultList.java
│ ├── SingleRead.java
│ ├── SingleReadQueryAdapter.java
│ ├── SingleReadWithColumns.java
│ ├── SingleReadWithUnit.java
│ ├── Update.java
│ ├── UpdateQueryAdapter.java
│ ├── UpdateWithUnit.java
│ ├── UpdateWithUnitAndCounter.java
│ ├── WithCounter.java
│ ├── Write.java
│ ├── WriteWithCounter.java
│ ├── WriteWithCounterQueryAdapter.java
│ └── interceptor
│ ├── CascadeOnDeleteInterceptor.java
│ ├── CascadeOnWriteInterceptor.java
│ ├── DeleteQueryRequestInterceptor.java
│ ├── ReadQueryData.java
│ ├── ReadQueryRequestInterceptor.java
│ ├── ReadQueryResponseInterceptor.java
│ ├── RecordListAdapter.java
│ ├── WriteQueryData.java
│ └── WriteQueryRequestInterceptor.java
└── test
├── java
└── net
│ └── oneandone
│ └── troilus
│ ├── BeanMapperReadTest.java
│ ├── BeanMapperWriteTest.java
│ ├── CassandraDB.java
│ ├── CompilerCheck.java
│ ├── SimpleResultList.java
│ ├── UserType.java
│ ├── api
│ ├── BatchingWithMultiSessionTest.java
│ ├── CollectionsTest.java
│ ├── ColumnsApiTest.java
│ ├── ExpliciteKeyspacenameTest.java
│ ├── FeesTable.java
│ ├── HistoryTable.java
│ ├── HistoryTableTest.java
│ ├── IdsTable.java
│ ├── InterceptorTest.java
│ ├── LoginsTable.java
│ ├── NativeTest.java
│ ├── PaginationInvites.java
│ ├── PaginationTest.java
│ ├── PartialReadTest.java
│ ├── PlusLoginsTable.java
│ ├── ReadWithConditionTest.java
│ ├── SessionReplacedTest.java
│ ├── UserDefinedFunctionsTest.java
│ ├── UserType.java
│ ├── UsersTable.java
│ ├── UsersTableFields.java
│ └── WideRowTest.java
│ ├── async
│ └── AsyncTest.java
│ ├── cascade
│ ├── CascadingTest.java
│ ├── DaoManager.java
│ ├── KeyByAccountColumns.java
│ └── KeyByEmailColumns.java
│ ├── example
│ ├── Address.java
│ ├── AddressType.java
│ ├── ClassifierEnum.java
│ ├── Functions.java
│ ├── Hotel.java
│ ├── HotelSubscriber.java
│ ├── HotelTableFields.java
│ ├── HotelTest.java
│ ├── HotelsTable.java
│ └── RoomsTable.java
│ ├── persistence
│ ├── EntityInheritanceMappingTest.java
│ ├── EntityMappingTest.java
│ ├── JPAEntityMappingTest.java
│ ├── JPAUser.java
│ ├── MinimalUser.java
│ └── User.java
│ ├── reactive
│ ├── MySubscriber.java
│ ├── PublisherFetchingTest.java
│ ├── PublisherTckTest.java
│ └── ReactiveTest.java
│ ├── referentialintegrity
│ ├── DeviceTable.java
│ ├── DeviceTest.java
│ ├── Immutables.java
│ ├── PhonenumbersConstraints.java
│ └── PhonenumbersTable.java
│ └── userdefinieddatatypes
│ ├── Addr.java
│ ├── AddrType.java
│ ├── Addressline.java
│ ├── AddresslineType.java
│ ├── Classifier.java
│ ├── ClassifierType.java
│ ├── CustomersTable.java
│ ├── Score.java
│ ├── ScoreType.java
│ ├── UDTValueMappingCollectionTests.java
│ └── UserDefinedDataTypesTest.java
└── resources
├── cassandra.yaml
├── com
└── unitedinternet
│ └── troilus
│ └── example
│ ├── addr.ddl
│ ├── address.ddl
│ ├── addressline.ddl
│ ├── classifier.ddl
│ ├── customers.ddl
│ ├── device.ddl
│ ├── fees.ddl
│ ├── functions.ddl
│ ├── history.ddl
│ ├── hotels.ddl
│ ├── ids.ddl
│ ├── invites.ddl
│ ├── key_by_accountid.ddl
│ ├── key_by_email.ddl
│ ├── logins.ddl
│ ├── phone_numbers.ddl
│ ├── plus_logins.ddl
│ ├── rooms.ddl
│ ├── score.ddl
│ └── users.ddl
└── logback-test.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /.project
2 | /troilus-service-example/target
3 | /troilus-service-example/tomcat.9080
4 | /troilus-service-example/.classpath
5 | /troilus-service-example/.project
6 | /troilus-service-example/.settings
7 | /troilus-core-minimal/.classpath
8 | /troilus-core-minimal/.project
9 | /troilus-core-minimal/target
10 | /troilus-core-minimal/.settings
11 | /troilus-core-java7/.settings
12 | /troilus-core-java7/target
13 | /troilus-core-java7/.classpath
14 | /troilus-core-java7/.project
15 | /target
16 | /troilus-core/test-output
17 | /troilus-core/src/test/java/net/oneandone/troilus/DeleteMe.java
18 | /troilus-service-example/test-output
19 | /troilus-service-example/tomcat.0
20 | /troilus-service-example/bin
21 |
--------------------------------------------------------------------------------
/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.core.resources.prefs
2 | /org.eclipse.m2e.core.prefs
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 | # - oraclejdk7
5 |
--------------------------------------------------------------------------------
/build.txt:
--------------------------------------------------------------------------------
1 |
2 | VERIFY
3 | # mvn -P foss-parent-verification clean verify -Denforcer.fail=false -Dcheckstyle.skip=true -Dpmd.skip=true -Djacoco.skip=true -Dcpd.skip=true -Dmaven.test.skip=true
4 | mvn -P foss-parent-verification clean verify -Denforcer.fail=false -Dcheckstyle.skip=true -Dpmd.skip=true -Djacoco.skip=true -Dcpd.skip=true
5 |
6 | PREPARE
7 | mvn release:prepare -DpushChanges=false
8 |
9 | RELEASE
10 | mvn release:perform -DpushChanges=false -DlocalCheckout=true -Darguments="-Denforcer.fail=false -Dcheckstyle.skip=true -Dpmd.skip=true -Djacoco.skip=true -Dlicense.skip=true -Dcpd.skip=true -Dmaven.test.skip=true"
11 | // -Dadditionalparam=-Xdoclint:none
12 |
13 | STAGING REPO
14 | https://oss.sonatype.org/#stagingRepositories
15 |
16 | TAGGING
17 | https://github.com/1and1/Troilus/releases
18 |
--------------------------------------------------------------------------------
/changes.txt:
--------------------------------------------------------------------------------
1 | 0.19
2 | * Update Guava to 30.0-jre
3 |
4 | 0.18
5 | * Fixed the putMapValue(...) method(s) in Write API to successfully add/update User Defined Type's into a datatype of map
6 | * Introduced a new Deletion API to remove a map value (ie: Deletion.removeMapValue(...))
7 |
8 | 0.17
9 | * Pagination Support - ListRead.withPagingState(), ListReadQuery.toStatementAsync()
10 | * Inheritance of @Field mappings for entities in BeanMapper
11 | * Upgrade from Cassandra Datastax 2.2.0-rc2 driver to 3.0.0-rc1 driver
12 | * Upgrade tests from Cassandra 2.x to Cassandra 3.0.0 (see pom.xml dependency and CassandraDB.java)
13 | * LocalDateTime Support - Record.java interfaces and implementations
14 | * bugfix: WriteQueryDataImpl.java toUpdateStatementAsync() no longer maps primary keys into Update SET
15 | * bugfix: RecordImpl.PropertySourceAdapter rewrote read() and read(String name, Class> clazz1, Class> clazz2) to work with UDTValue collections.
16 | * New test cases: PaginationTest.java, EntityInheritanceMappingTest.java, UDTValueMappingCollectionTests.java
17 |
18 | 0.16
19 | * DaoImpl constructor supports keyspacename paramter instead dot-composed keyspace and tablename string
20 |
21 | 0.15
22 | * bugfix: Prepared statement can no longer be executed by other sessions than the session which prepared the statement. This could result in invalid prepared sessions
23 |
24 | 0.14
25 | * bugfix: removing invalid cached prepared statements: internal prepared statement cache will be invalidated, if a host goes up or an internal driver error occurs
26 |
27 | 0.12
28 | * reactive-streams dependency set to 1.0.0.RC5
--------------------------------------------------------------------------------
/troilus-core-java7/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | net.oneandone.troilus
7 | troilus-parent
8 | 0.19-SNAPSHOT
9 |
10 | troilus-core-java7
11 | jar
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | org.apache.maven.plugins
21 | maven-compiler-plugin
22 | 3.1
23 |
24 | 1.7
25 | 1.7
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/ConstraintException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 |
20 |
21 |
22 | /**
23 | * Exception thrown when a constraint is violated
24 | */
25 | public class ConstraintException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = 4270476820995364200L;
28 |
29 | /**
30 | * @param message the message to report
31 | */
32 | public ConstraintException(String message) {
33 | super(message);
34 | }
35 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/Count.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import com.datastax.driver.core.ExecutionInfo;
19 |
20 | import com.datastax.driver.core.ResultSet;
21 | import com.google.common.collect.ImmutableList;
22 |
23 |
24 |
25 | /**
26 | * The count result
27 | */
28 | public abstract class Count implements Result {
29 |
30 | /**
31 | * @return the count value
32 | */
33 | public abstract long getCount();
34 |
35 | /**
36 | * @param rs the result set
37 | * @return the associated count result
38 | */
39 | static Count newCountResult(ResultSet rs) {
40 | return new CountResultImpl(rs);
41 | }
42 |
43 |
44 | private static final class CountResultImpl extends Count {
45 | private final ResultSet rs;
46 | private final long count;
47 |
48 |
49 | private CountResultImpl(ResultSet rs) {
50 | this.rs = rs;
51 | this.count = rs.one().getLong("count");
52 | }
53 |
54 | @Override
55 | public ExecutionInfo getExecutionInfo() {
56 | return rs.getExecutionInfo();
57 | }
58 |
59 | @Override
60 | public ImmutableList getAllExecutionInfo() {
61 | return ImmutableList.copyOf(rs.getAllExecutionInfo());
62 | }
63 |
64 | @Override
65 | public boolean wasApplied() {
66 | return rs.wasApplied();
67 | }
68 |
69 | @Override
70 | public long getCount() {
71 | return count;
72 | }
73 | }
74 | }
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/CounterBatchMutationQuery.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 |
20 | import net.oneandone.troilus.java7.CounterMutation;
21 |
22 | import com.datastax.driver.core.BatchStatement.Type;
23 | import com.datastax.driver.core.Statement;
24 | import com.google.common.base.Function;
25 | import com.google.common.collect.ImmutableList;
26 | import com.google.common.util.concurrent.ListenableFuture;
27 |
28 |
29 |
30 | /**
31 | * Counter batch mutation query
32 | *
33 | */
34 | class CounterBatchMutationQuery extends MutationQuery implements CounterMutation {
35 | private final ImmutableList batchables;
36 |
37 | /**
38 | * @param ctx the context to use
39 | * @param batchables the statements to be performed within the batch
40 | */
41 | CounterBatchMutationQuery(Context ctx, ImmutableList batchables) {
42 | super(ctx);
43 | this.batchables = batchables;
44 | }
45 |
46 |
47 | ////////////////////
48 | // factory methods
49 |
50 | @Override
51 | protected CounterBatchMutationQuery newQuery(Context newContext) {
52 | return new CounterBatchMutationQuery(newContext, batchables);
53 | }
54 |
55 | private CounterBatchMutationQuery newQuery(ImmutableList batchables) {
56 | return new CounterBatchMutationQuery(getContext(), batchables);
57 | }
58 |
59 | //
60 | ////////////////////
61 |
62 |
63 | @Override
64 | public CounterBatchMutationQuery combinedWith(CounterMutation other) {
65 | return newQuery(Immutables.join(batchables, other));
66 | }
67 |
68 | @Override
69 | public ListenableFuture getStatementAsync(final DBSession dbSession) {
70 |
71 | Function> statementFetcher = new Function>() {
72 | public ListenableFuture apply(CounterMutation batchable) {
73 | return batchable.getStatementAsync(dbSession);
74 | };
75 | };
76 | return mergeToBatch(Type.COUNTER, batchables.iterator(), statementFetcher);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/CounterMutationQuery.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import com.google.common.util.concurrent.MoreExecutors;
19 | import net.oneandone.troilus.java7.CounterMutation;
20 |
21 | import com.datastax.driver.core.ResultSet;
22 | import com.datastax.driver.core.Statement;
23 | import com.google.common.base.Function;
24 | import com.google.common.collect.ImmutableList;
25 | import com.google.common.util.concurrent.Futures;
26 | import com.google.common.util.concurrent.ListenableFuture;
27 |
28 |
29 | /**
30 | * Counter mutation query implementation
31 | *
32 | */
33 | class CounterMutationQuery extends AbstractQuery implements CounterMutation {
34 |
35 | private final CounterMutationQueryData data;
36 |
37 | /**
38 | * @param ctx the context
39 | * @param data the query data
40 | */
41 | CounterMutationQuery(Context ctx, CounterMutationQueryData data) {
42 | super(ctx);
43 | this.data = data;
44 | }
45 |
46 | @Override
47 | protected CounterMutationQuery newQuery(Context newContext) {
48 | return new CounterMutationQuery(newContext, data);
49 | }
50 |
51 |
52 | @Override
53 | public CounterBatchMutationQuery combinedWith(CounterMutation other) {
54 | return new CounterBatchMutationQuery(getContext(), ImmutableList.of(this, other));
55 | }
56 |
57 | @Override
58 | public Result execute() {
59 | return ListenableFutures.getUninterruptibly(executeAsync());
60 | }
61 |
62 | @Override
63 | public ListenableFuture executeAsync() {
64 | ListenableFuture future = performAsync(getDefaultDbSession(), getStatementAsync(getDefaultDbSession()));
65 |
66 | Function mapEntity = new Function() {
67 | @Override
68 | public Result apply(ResultSet resultSet) {
69 | return newResult(resultSet);
70 | }
71 | };
72 |
73 | return Futures.transform(future, mapEntity, MoreExecutors.directExecutor());
74 | }
75 |
76 |
77 | @Override
78 | public ListenableFuture getStatementAsync(DBSession dbSession) {
79 | return data.toStatementAsync(getExecutionSpec(), dbSession, data.getTablename());
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/DataTypes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import com.datastax.driver.core.DataType;
19 |
20 |
21 |
22 |
23 |
24 |
25 | class DataTypes {
26 |
27 | public static boolean isTextDataType(DataType dataType) {
28 | return dataType.equals(DataType.text()) ||
29 | dataType.equals(DataType.ascii()) ||
30 | dataType.equals(DataType.varchar());
31 | }
32 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/ExecutionSpec.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 | import com.datastax.driver.core.ConsistencyLevel;
20 | import com.datastax.driver.core.policies.RetryPolicy;
21 |
22 |
23 |
24 |
25 | public interface ExecutionSpec {
26 |
27 | ExecutionSpec withConsistency(ConsistencyLevel consistencyLevel);
28 |
29 | ExecutionSpec withSerialConsistency(ConsistencyLevel consistencyLevel);
30 |
31 | ExecutionSpec withTtl(int ttlSec);
32 |
33 | ExecutionSpec withWritetime(long microsSinceEpoch);
34 |
35 | ExecutionSpec withTracking();
36 |
37 | ExecutionSpec withoutTracking();
38 |
39 | ExecutionSpec withRetryPolicy(RetryPolicy policy);
40 |
41 | ConsistencyLevel getConsistencyLevel();
42 |
43 | ConsistencyLevel getSerialConsistencyLevel();
44 |
45 | Integer getTtl();
46 |
47 | Long getWritetime();
48 |
49 | Boolean getEnableTracing();
50 |
51 | RetryPolicy getRetryPolicy();
52 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/Field.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 |
24 | /**
25 | * Annotation that allows to specify the name of the CQL field to which the Java field should be mapped.
26 | *
27 | */
28 | @Target(ElementType.FIELD)
29 | @Retention(RetentionPolicy.RUNTIME)
30 | public @interface Field {
31 |
32 | /**
33 | * @return the CQL field
34 | */
35 | String name();
36 | }
37 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/IfConditionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 |
20 |
21 |
22 | /**
23 | * Exception thrown when a if condition is violated
24 | */
25 | public class IfConditionException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = -4815247201091574807L;
28 |
29 | private transient final Result result;
30 |
31 | /**
32 | * @param message the message to report
33 | * @param result the result
34 | */
35 | public IfConditionException(Result result, String message) {
36 | super(message);
37 | this.result = result;
38 | }
39 |
40 | /**
41 | * @return the result
42 | */
43 | public Result getResult() {
44 | return result;
45 | }
46 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/InsertQuery.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import net.oneandone.troilus.java7.Insertion;
19 | import net.oneandone.troilus.java7.Batchable;
20 | import net.oneandone.troilus.java7.interceptor.WriteQueryData;
21 |
22 |
23 |
24 |
25 |
26 |
27 | /**
28 | * insert query implementation
29 | */
30 | class InsertQuery extends WriteQuery implements Insertion {
31 |
32 |
33 | /**
34 | * @param ctx the context
35 | * @param data the data
36 | */
37 | InsertQuery(Context ctx, WriteQueryData data) {
38 | super(ctx, data);
39 | }
40 |
41 |
42 | ////////////////////
43 | // factory methods
44 |
45 | @Override
46 | protected InsertQuery newQuery(Context newContext) {
47 | return new InsertQuery(newContext, getData());
48 | }
49 |
50 | private InsertQuery newQuery(WriteQueryData data) {
51 | return new InsertQuery(getContext(), data);
52 | }
53 |
54 | //
55 | ////////////////////
56 |
57 |
58 | @Override
59 | public BatchMutationQuery combinedWith(Batchable> other) {
60 | return new BatchMutationQuery(getContext(), this, other);
61 | }
62 |
63 | @Override
64 | public InsertQuery withTtl(int ttlSec) {
65 | return newQuery(getContext().withTtl(ttlSec));
66 | }
67 |
68 | @Override
69 | public InsertQuery ifNotExists() {
70 | return newQuery(getData().ifNotExists(true));
71 | }
72 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/PropertiesSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import com.google.common.base.Optional;
19 |
20 |
21 |
22 | /**
23 | * Properties source
24 | */
25 | interface PropertiesSource {
26 |
27 | /**
28 | * @param name the property name
29 | * @param clazz the property type
30 | * @return the property value
31 | */
32 | Optional read(String name, Class> clazz);
33 |
34 | /**
35 | * @param name the property source
36 | * @param clazz1 the property type of element 1 (e.g. key type of map)
37 | * @param clazz2 the property type of element 2 (e.g. value type of map)
38 | * @return the property value
39 | */
40 | Optional read(String name, Class> clazz1, Class> clazz2);
41 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/ProtocolErrorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 |
20 | /**
21 | * Exception thrown when a protocol-level error occurs
22 | *
23 | */
24 | public class ProtocolErrorException extends RuntimeException {
25 |
26 | private static final long serialVersionUID = 4270476820995364200L;
27 |
28 | /**
29 | * @param message the message to report
30 | */
31 | public ProtocolErrorException(String message) {
32 | super(message);
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/Result.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 | import com.datastax.driver.core.ExecutionInfo;
20 | import com.google.common.collect.ImmutableList;
21 |
22 |
23 | /**
24 | * The query result
25 | */
26 | public interface Result {
27 |
28 | /**
29 | * @return the execution info for the last query made for this ResultSet
30 | */
31 | ExecutionInfo getExecutionInfo();
32 |
33 | /**
34 | * @return a list of the execution info for all the queries made for this ResultSet
35 | */
36 | ImmutableList getAllExecutionInfo();
37 |
38 | /**
39 | * @return if the query was a conditional update, whether it was applied. true for other types of queries.
40 | */
41 | boolean wasApplied();
42 | }
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/ResultAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 | import com.datastax.driver.core.ExecutionInfo;
20 | import com.google.common.collect.ImmutableList;
21 |
22 |
23 | /**
24 | * query result adapter
25 | */
26 | abstract class ResultAdapter implements Result {
27 |
28 | private final Result result;
29 |
30 | /**
31 | * @param result the underlying result
32 | */
33 | ResultAdapter(Result result) {
34 | this.result = result;
35 | }
36 |
37 | @Override
38 | public ExecutionInfo getExecutionInfo() {
39 | return result.getExecutionInfo();
40 | }
41 |
42 | @Override
43 | public ImmutableList getAllExecutionInfo() {
44 | return result.getAllExecutionInfo();
45 | }
46 |
47 | @Override
48 | public boolean wasApplied() {
49 | return result.wasApplied();
50 | }
51 | }
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/Tablename.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 | import com.datastax.driver.core.Session;
19 | import com.google.common.base.Objects;
20 |
21 |
22 |
23 | /**
24 | * Tablename
25 | */
26 | public class Tablename {
27 |
28 | private String keyspacename;
29 | private String tablename;
30 |
31 |
32 | /**
33 | * @param session the session
34 | * @param tablename the tablename
35 | * @return hte tablename object
36 | */
37 | static Tablename newTablename(Session session, String tablename) {
38 | String keyspacename = session.getLoggedKeyspace();
39 |
40 | if (keyspacename == null) {
41 | throw new IllegalStateException("no keyspace assigned");
42 | }
43 |
44 | return newTablename(keyspacename, tablename);
45 | }
46 |
47 |
48 | /**
49 | * @param tablename the tablename
50 | * @param keyspacename the keyspacename
51 | * @return hte tablename object
52 | */
53 | static Tablename newTablename(String keyspacename, String tablename) {
54 | return new Tablename(keyspacename, tablename);
55 | }
56 |
57 | private Tablename(String keyspacename, String tablename) {
58 | this.keyspacename = keyspacename;
59 | this.tablename = tablename;
60 | }
61 |
62 |
63 | /**
64 | * @return the keyspaceanme or null
65 | */
66 | String getKeyspacename() {
67 | return keyspacename;
68 | }
69 |
70 | /**
71 | * @return the tablename
72 | */
73 | public String getTablename() {
74 | return tablename;
75 | }
76 |
77 | @Override
78 | public boolean equals(Object other) {
79 | return (other instanceof Tablename) &&
80 | Objects.equal(((Tablename) other).keyspacename, this.keyspacename) &&
81 | Objects.equal(((Tablename) other).tablename, this.tablename);
82 | }
83 |
84 | @Override
85 | public int hashCode() {
86 | return toString().hashCode();
87 | }
88 |
89 | @Override
90 | public String toString() {
91 | return (keyspacename == null) ? tablename : keyspacename + "." + tablename;
92 | }
93 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/TooManyResultsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus;
17 |
18 |
19 |
20 |
21 | /**
22 | * Exception thrown when a more results (rows) are returned than expected
23 | */
24 | public class TooManyResultsException extends RuntimeException {
25 |
26 | private static final long serialVersionUID = 4270476820995364200L;
27 |
28 | private transient final Result result;
29 |
30 | /**
31 | * @param message the message to report
32 | * @param result the result
33 | */
34 | public TooManyResultsException(Result result, String message) {
35 | super(message);
36 | this.result = result;
37 | }
38 |
39 | /**
40 | * @return the result
41 | */
42 | public Result getResult() {
43 | return result;
44 | }
45 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/interceptor/DeleteQueryData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.interceptor;
17 |
18 |
19 |
20 | import java.util.List;
21 |
22 | import net.oneandone.troilus.Tablename;
23 |
24 | import com.datastax.driver.core.querybuilder.Clause;
25 | import com.google.common.collect.ImmutableList;
26 | import com.google.common.collect.ImmutableMap;
27 |
28 |
29 |
30 |
31 |
32 | /**
33 | * Delete query data
34 | */
35 | public interface DeleteQueryData {
36 |
37 | /**
38 | * @return the tablename
39 | */
40 | Tablename getTablename();
41 |
42 | /**
43 | * @param key the key
44 | * @return the new delete query data
45 | */
46 | DeleteQueryData key(ImmutableMap key);
47 |
48 | /**
49 | * returns map of values to remove from column family
50 | * @return
51 | */
52 | ImmutableMap> getMapValuesToRemove();
53 |
54 | /**
55 | * this method's purpose is to populate the list of map
56 | * values to remove
57 | *
58 | * @param removedMapValues
59 | * @return
60 | */
61 | DeleteQueryData mapValuesToRemove(ImmutableMap> removedMapValues);
62 | /**
63 | * @param whereConditions the where conditions
64 | * @return the new delete query data
65 | */
66 | DeleteQueryData whereConditions(ImmutableList whereConditions);
67 |
68 | /**
69 | * @param onlyIfConditions the onlyIf conditions
70 | * @return the new delete query data
71 | */
72 | DeleteQueryData onlyIfConditions(ImmutableList onlyIfConditions);
73 |
74 | /**
75 | * @param IfExists the ifNotExits conditions
76 | * @return the new delete query data
77 | */
78 | DeleteQueryData ifExists(Boolean IfExists);
79 |
80 | /**
81 | * @return the key
82 | */
83 | ImmutableMap getKey();
84 |
85 | /**
86 | * @return the where conditions
87 | */
88 | ImmutableList getWhereConditions();
89 |
90 | /**
91 | * @return the onlyIf conditions
92 | */
93 | ImmutableList getOnlyIfConditions();
94 |
95 | /**
96 | * @return the ifExists flag
97 | */
98 | Boolean getIfExists();
99 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/interceptor/QueryInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.interceptor;
17 |
18 |
19 |
20 |
21 | /**
22 | * QueryInterceptor marker interface
23 | */
24 | public interface QueryInterceptor {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/interceptor/SingleReadQueryData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.interceptor;
17 |
18 | import com.google.common.collect.ImmutableMap;
19 |
20 |
21 |
22 |
23 | /**
24 | * The reqd query data
25 | *
26 | */
27 | public interface SingleReadQueryData {
28 |
29 | /**
30 | * @param key the key
31 | * @return the new read query data
32 | */
33 | SingleReadQueryData key(ImmutableMap key);
34 |
35 | /**
36 | * @param columnsToFetchs the columns to fetch
37 | * @return the new read query data
38 | */
39 | SingleReadQueryData columnsToFetch(ImmutableMap columnsToFetchs);
40 |
41 | /**
42 | * @return the key
43 | */
44 | ImmutableMap getKey();
45 |
46 | /**
47 | * @return the columns to fetch
48 | */
49 | ImmutableMap getColumnsToFetch();
50 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/java7/BatchMutation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.java7;
17 |
18 | import net.oneandone.troilus.Result;
19 |
20 |
21 | /**
22 | * BatchMutation
23 | */
24 | public interface BatchMutation extends Batchable {
25 |
26 | /**
27 | * @return a cloned query instance with write ahead log
28 | */
29 | Mutation withWriteAheadLog();
30 |
31 | /**
32 | * @return a cloned query instance without write ahead log
33 | */
34 | Mutation withoutWriteAheadLog();
35 | }
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/java7/Batchable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.java7;
17 |
18 | import net.oneandone.troilus.Result;
19 |
20 |
21 |
22 | /**
23 | * Batchable Mutation query
24 | *
25 | * @param the query type
26 | */
27 | public interface Batchable> extends Mutation {
28 |
29 |
30 | /**
31 | * @param other the other query to combine with. If other is null, this query will be returned
32 | * @return a cloned query instance with the modified behavior
33 | */
34 | BatchMutation combinedWith(Batchable> other);
35 | }
36 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/java7/BatchableWithTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.java7;
17 |
18 |
19 |
20 | /**
21 | * Batchable mutation query (insert or update)
22 | * @param the query type
23 | */
24 | public interface BatchableWithTime> extends Batchable {
25 |
26 | /**
27 | * @param ttlSec the time-to-live in sec to set
28 | * @return a cloned query instance with the modified behavior
29 | */
30 | BatchableWithTime withTtl(int ttlSec);
31 |
32 | /**
33 | * @param microsSinceEpoch the writetime in since epoch to set
34 | * @return a cloned query instance with the modified behavior
35 | */
36 | BatchableWithTime withWritetime(long microsSinceEpoch);
37 | }
38 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/java7/CounterMutation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.java7;
17 |
18 | import net.oneandone.troilus.Result;
19 |
20 |
21 | /**
22 | * counter mutation
23 | */
24 | public interface CounterMutation extends Mutation {
25 |
26 | /**
27 | * @param ttlSec the time-to-live to set
28 | * @return a cloned query instance with the modified behavior
29 | */
30 | CounterMutation withTtl(int ttlSec);
31 |
32 | /**
33 | * @param microsSinceEpoch the writetime in since epoch to set
34 | * @return a cloned query instance with the modified behavior
35 | */
36 | CounterMutation withWritetime(long microsSinceEpoch);
37 |
38 | /**
39 | * @param other the other query to combine with
40 | * @return a cloned query instance with the modified behavior
41 | */
42 | CounterMutation combinedWith(CounterMutation other);
43 | }
44 |
--------------------------------------------------------------------------------
/troilus-core-java7/src/main/java/net/oneandone/troilus/java7/Deletion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1&1 Internet AG, https://github.com/1and1/
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package net.oneandone.troilus.java7;
17 |
18 | import java.util.Map;
19 |
20 | import net.oneandone.troilus.ColumnName;
21 | import net.oneandone.troilus.Result;
22 |
23 | import com.datastax.driver.core.querybuilder.Clause;
24 |
25 |
26 | /**
27 | * delete query
28 | */
29 | public interface Deletion extends Batchable {
30 |
31 | /**
32 | * @param conditions the conditions
33 | * @return a cloned query instance with lwt (only-if)
34 | */
35 | Mutation onlyIf(Clause... conditions);
36 |
37 | /**
38 | * @return a cloned query instance with lwt (if-exits)
39 | */
40 | Mutation ifExists();
41 |
42 | /**
43 | * this method will remove a provided map entry for a column
44 | * of type "map" in repository
45 | *
46 | * @param columnName
47 | * @param mapKey
48 | * @return
49 | */
50 | Deletion removeMapValue(String columnName, Object mapKey);
51 |
52 | /**
53 | * this method allows the caller to provide a ColumnName object
54 | * and a mapKey to remove a map entry
55 | *
56 | */
57 | Deletion removeMapValue(ColumnName