Merge branch 'develop' into gburd/wip-facet-cache
This commit is contained in:
commit
32b06e1494
29 changed files with 159 additions and 62 deletions
|
@ -17,7 +17,13 @@ package net.helenus.core.operation;
|
||||||
|
|
||||||
import com.codahale.metrics.Timer;
|
import com.codahale.metrics.Timer;
|
||||||
import com.datastax.driver.core.ResultSet;
|
import com.datastax.driver.core.ResultSet;
|
||||||
|
|
||||||
|
import java.sql.Time;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import com.diffplug.common.base.Errors;
|
||||||
import net.helenus.core.AbstractSessionOperations;
|
import net.helenus.core.AbstractSessionOperations;
|
||||||
import net.helenus.core.UnitOfWork;
|
import net.helenus.core.UnitOfWork;
|
||||||
|
|
||||||
|
@ -38,22 +44,22 @@ public abstract class AbstractOperation<E, O extends AbstractOperation<E, O>>
|
||||||
return new PreparedOperation<E>(prepareStatement(), this);
|
return new PreparedOperation<E>(prepareStatement(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public E sync() {
|
public E sync() throws TimeoutException {
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
try {
|
try {
|
||||||
ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false);
|
ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false);
|
||||||
return transform(resultSet);
|
return transform(resultSet);
|
||||||
} finally {
|
} finally {
|
||||||
context.stop();
|
context.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public E sync(UnitOfWork uow) {
|
public E sync(UnitOfWork uow) throws TimeoutException {
|
||||||
if (uow == null) return sync();
|
if (uow == null) return sync();
|
||||||
|
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
try {
|
try {
|
||||||
ResultSet resultSet = execute(sessionOps, uow, traceContext, showValues, true);
|
ResultSet resultSet = execute(sessionOps, uow, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, true);
|
||||||
E result = transform(resultSet);
|
E result = transform(resultSet);
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -62,11 +68,19 @@ public abstract class AbstractOperation<E, O extends AbstractOperation<E, O>>
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<E> async() {
|
public CompletableFuture<E> async() {
|
||||||
return CompletableFuture.<E>supplyAsync(() -> sync());
|
return CompletableFuture.<E>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<E> async(UnitOfWork uow) {
|
public CompletableFuture<E> async(UnitOfWork uow) {
|
||||||
if (uow == null) return async();
|
if (uow == null) return async();
|
||||||
return CompletableFuture.<E>supplyAsync(() -> sync(uow));
|
return CompletableFuture.<E>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.AbstractSessionOperations;
|
import net.helenus.core.AbstractSessionOperations;
|
||||||
import net.helenus.core.Filter;
|
import net.helenus.core.Filter;
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
|
@ -63,17 +66,17 @@ public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOpe
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<E> sync() {
|
public Optional<E> sync() throws TimeoutException {
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
try {
|
try {
|
||||||
ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false);
|
ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false);
|
||||||
return transform(resultSet);
|
return transform(resultSet);
|
||||||
} finally {
|
} finally {
|
||||||
context.stop();
|
context.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<E> sync(UnitOfWork uow) {
|
public Optional<E> sync(UnitOfWork uow) throws TimeoutException {
|
||||||
if (uow == null) return sync();
|
if (uow == null) return sync();
|
||||||
|
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
|
@ -120,8 +123,7 @@ public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOpe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
uowCacheMiss.mark();
|
ResultSet resultSet = execute(sessionOps, uow, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, true);
|
||||||
ResultSet resultSet = execute(sessionOps, uow, traceContext, showValues, true);
|
|
||||||
result = transform(resultSet);
|
result = transform(resultSet);
|
||||||
|
|
||||||
if (enableCache && result.isPresent()) {
|
if (enableCache && result.isPresent()) {
|
||||||
|
@ -164,11 +166,19 @@ public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOpe
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Optional<E>> async() {
|
public CompletableFuture<Optional<E>> async() {
|
||||||
return CompletableFuture.<Optional<E>>supplyAsync(() -> sync());
|
return CompletableFuture.<Optional<E>>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Optional<E>> async(UnitOfWork uow) {
|
public CompletableFuture<Optional<E>> async(UnitOfWork uow) {
|
||||||
if (uow == null) return async();
|
if (uow == null) return async();
|
||||||
return CompletableFuture.<Optional<E>>supplyAsync(() -> sync(uow));
|
return CompletableFuture.<Optional<E>>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ import net.helenus.support.HelenusException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public abstract class AbstractStatementOperation<E, O extends AbstractStatementOperation<E, O>>
|
public abstract class AbstractStatementOperation<E, O extends AbstractStatementOperation<E, O>>
|
||||||
extends Operation<E> {
|
extends Operation<E> {
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ public abstract class AbstractStatementOperation<E, O extends AbstractStatementO
|
||||||
private boolean enableTracing = false;
|
private boolean enableTracing = false;
|
||||||
private long[] defaultTimestamp = null;
|
private long[] defaultTimestamp = null;
|
||||||
private int[] fetchSize = null;
|
private int[] fetchSize = null;
|
||||||
|
long queryExecutionTimeout = 10;
|
||||||
|
TimeUnit queryTimeoutUnits = TimeUnit.SECONDS;
|
||||||
|
|
||||||
public AbstractStatementOperation(AbstractSessionOperations sessionOperations) {
|
public AbstractStatementOperation(AbstractSessionOperations sessionOperations) {
|
||||||
super(sessionOperations);
|
super(sessionOperations);
|
||||||
|
@ -203,6 +207,18 @@ public abstract class AbstractStatementOperation<E, O extends AbstractStatementO
|
||||||
return (O) this;
|
return (O) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public O queryTimeoutMs(long ms) {
|
||||||
|
this.queryExecutionTimeout = ms;
|
||||||
|
this.queryTimeoutUnits = TimeUnit.MILLISECONDS;
|
||||||
|
return (O) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public O queryTimeout(long timeout, TimeUnit units) {
|
||||||
|
this.queryExecutionTimeout = timeout;
|
||||||
|
this.queryTimeoutUnits = units;
|
||||||
|
return (O) this;
|
||||||
|
}
|
||||||
|
|
||||||
public Statement options(Statement statement) {
|
public Statement options(Statement statement) {
|
||||||
|
|
||||||
if (defaultTimestamp != null) {
|
if (defaultTimestamp != null) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import net.helenus.core.AbstractSessionOperations;
|
import net.helenus.core.AbstractSessionOperations;
|
||||||
import net.helenus.core.UnitOfWork;
|
import net.helenus.core.UnitOfWork;
|
||||||
|
@ -52,17 +54,17 @@ public abstract class AbstractStreamOperation<E, O extends AbstractStreamOperati
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<E> sync() {
|
public Stream<E> sync() throws TimeoutException {
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
try {
|
try {
|
||||||
ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false);
|
ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false);
|
||||||
return transform(resultSet);
|
return transform(resultSet);
|
||||||
} finally {
|
} finally {
|
||||||
context.stop();
|
context.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<E> sync(UnitOfWork uow) {
|
public Stream<E> sync(UnitOfWork uow) throws TimeoutException {
|
||||||
if (uow == null) return sync();
|
if (uow == null) return sync();
|
||||||
|
|
||||||
final Timer.Context context = requestLatency.time();
|
final Timer.Context context = requestLatency.time();
|
||||||
|
@ -82,7 +84,7 @@ public abstract class AbstractStreamOperation<E, O extends AbstractStreamOperati
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ResultSet resultSet = execute(sessionOps, uow, traceContext, showValues, true);
|
ResultSet resultSet = execute(sessionOps, uow, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, true);
|
||||||
result = transform(resultSet);
|
result = transform(resultSet);
|
||||||
|
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
|
@ -97,11 +99,19 @@ public abstract class AbstractStreamOperation<E, O extends AbstractStreamOperati
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Stream<E>> async() {
|
public CompletableFuture<Stream<E>> async() {
|
||||||
return CompletableFuture.<Stream<E>>supplyAsync(() -> sync());
|
return CompletableFuture.<Stream<E>>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Stream<E>> async(UnitOfWork uow) {
|
public CompletableFuture<Stream<E>> async(UnitOfWork uow) {
|
||||||
if (uow == null) return async();
|
if (uow == null) return async();
|
||||||
return CompletableFuture.<Stream<E>>supplyAsync(() -> sync(uow));
|
return CompletableFuture.<Stream<E>>supplyAsync(() -> {
|
||||||
|
try {
|
||||||
|
return sync();
|
||||||
|
} catch (TimeoutException ex) { throw new CompletionException(ex); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.datastax.driver.core.querybuilder.Insert;
|
||||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import net.helenus.core.AbstractSessionOperations;
|
import net.helenus.core.AbstractSessionOperations;
|
||||||
import net.helenus.core.Getter;
|
import net.helenus.core.Getter;
|
||||||
|
@ -257,7 +258,7 @@ public final class InsertOperation<T> extends AbstractOperation<T, InsertOperati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T sync(UnitOfWork uow) {
|
public T sync(UnitOfWork uow) throws TimeoutException {
|
||||||
if (uow == null) {
|
if (uow == null) {
|
||||||
return sync();
|
return sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,12 @@ import com.datastax.driver.core.ResultSetFuture;
|
||||||
import com.datastax.driver.core.Statement;
|
import com.datastax.driver.core.Statement;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.AbstractSessionOperations;
|
import net.helenus.core.AbstractSessionOperations;
|
||||||
import net.helenus.core.UnitOfWork;
|
import net.helenus.core.UnitOfWork;
|
||||||
import net.helenus.core.cache.EntityIdentifyingFacet;
|
import net.helenus.support.HelenusException;
|
||||||
|
|
||||||
public abstract class Operation<E> {
|
public abstract class Operation<E> {
|
||||||
|
|
||||||
|
@ -34,8 +37,10 @@ public abstract class Operation<E> {
|
||||||
AbstractSessionOperations session,
|
AbstractSessionOperations session,
|
||||||
UnitOfWork uow,
|
UnitOfWork uow,
|
||||||
TraceContext traceContext,
|
TraceContext traceContext,
|
||||||
|
long timeout,
|
||||||
|
TimeUnit units,
|
||||||
boolean showValues,
|
boolean showValues,
|
||||||
boolean cached) {
|
boolean cached) throws TimeoutException {
|
||||||
|
|
||||||
// Start recording in a Zipkin sub-span our execution time to perform this operation.
|
// Start recording in a Zipkin sub-span our execution time to perform this operation.
|
||||||
Tracer tracer = session.getZipkinTracer();
|
Tracer tracer = session.getZipkinTracer();
|
||||||
|
@ -46,19 +51,14 @@ public abstract class Operation<E> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (span != null) {
|
if (span != null) {
|
||||||
span.name("cassandra");
|
span.name("cassandra");
|
||||||
span.start();
|
span.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = options(buildStatement(cached));
|
|
||||||
ResultSetFuture futureResultSet = session.executeAsync(statement, showValues);
|
|
||||||
return futureResultSet.get();
|
|
||||||
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
|
|
||||||
|
Statement statement = options(buildStatement(cached));
|
||||||
|
ResultSetFuture futureResultSet = session.executeAsync(statement, showValues);
|
||||||
|
return futureResultSet.getUninterruptibly(timeout, units);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (span != null) {
|
if (span != null) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||||
import com.datastax.driver.core.querybuilder.Select;
|
import com.datastax.driver.core.querybuilder.Select;
|
||||||
import com.datastax.driver.core.querybuilder.Select.Selection;
|
import com.datastax.driver.core.querybuilder.Select.Selection;
|
||||||
import com.datastax.driver.core.querybuilder.Select.Where;
|
import com.datastax.driver.core.querybuilder.Select.Where;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.datastax.driver.core.querybuilder.BuiltStatement;
|
||||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||||
import com.datastax.driver.core.querybuilder.Update;
|
import com.datastax.driver.core.querybuilder.Update;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import net.helenus.core.*;
|
import net.helenus.core.*;
|
||||||
import net.helenus.core.reflect.HelenusPropertyNode;
|
import net.helenus.core.reflect.HelenusPropertyNode;
|
||||||
|
@ -578,7 +579,7 @@ public final class UpdateOperation<E> extends AbstractFilterOperation<E, UpdateO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E sync(UnitOfWork uow) {
|
public E sync(UnitOfWork uow) throws TimeoutException {
|
||||||
if (uow == null) {
|
if (uow == null) {
|
||||||
return sync();
|
return sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
||||||
|
@ -51,7 +53,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetCRUID() {
|
public void testSetCRUID() throws TimeoutException {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCRUID() {
|
public void testListCRUID() throws TimeoutException {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
|
@ -278,7 +280,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapCRUID() {
|
public void testMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class CounterTest extends AbstractEmbeddedCassandraTest {
|
public class CounterTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
static Page page;
|
static Page page;
|
||||||
|
@ -42,7 +44,7 @@ public class CounterTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCounter() {
|
public void testCounter() throws TimeoutException {
|
||||||
|
|
||||||
boolean exists =
|
boolean exists =
|
||||||
session.select(page::hits).where(page::alias, eq("index")).sync().findFirst().isPresent();
|
session.select(page::hits).where(page::alias, eq("index")).sync().findFirst().isPresent();
|
||||||
|
|
|
@ -4,6 +4,8 @@ import static net.helenus.core.Query.eq;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
||||||
|
@ -35,7 +37,7 @@ public class HierarchyTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCounter() {
|
public void testCounter() throws TimeoutException {
|
||||||
|
|
||||||
session
|
session
|
||||||
.insert()
|
.insert()
|
||||||
|
@ -58,7 +60,7 @@ public class HierarchyTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultMethod() {
|
public void testDefaultMethod() throws TimeoutException {
|
||||||
session
|
session
|
||||||
.insert()
|
.insert()
|
||||||
.value(cat::id, rnd.nextInt())
|
.value(cat::id, rnd.nextInt())
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class SecondaryIndexTest extends AbstractEmbeddedCassandraTest {
|
public class SecondaryIndexTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
Book book;
|
Book book;
|
||||||
|
@ -36,7 +38,7 @@ public class SecondaryIndexTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws TimeoutException {
|
||||||
|
|
||||||
session
|
session
|
||||||
.insert()
|
.insert()
|
||||||
|
|
|
@ -19,6 +19,8 @@ import static net.helenus.core.Query.eq;
|
||||||
|
|
||||||
import com.datastax.driver.core.ResultSet;
|
import com.datastax.driver.core.ResultSet;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.core.Operator;
|
import net.helenus.core.Operator;
|
||||||
|
@ -234,7 +236,7 @@ public class SimpleUserTest extends AbstractEmbeddedCassandraTest {
|
||||||
Assert.assertEquals(0L, cnt);
|
Assert.assertEquals(0L, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testZipkin() throws Exception {
|
public void testZipkin() throws TimeoutException {
|
||||||
session
|
session
|
||||||
.update()
|
.update()
|
||||||
.set(user::name, null)
|
.set(user::name, null)
|
||||||
|
|
|
@ -17,6 +17,7 @@ package net.helenus.test.integration.core.simple;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
|
@ -82,7 +83,7 @@ public class StaticColumnTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRUID() {
|
public void testCRUID() throws TimeoutException {
|
||||||
|
|
||||||
MessageImpl msg = new MessageImpl();
|
MessageImpl msg = new MessageImpl();
|
||||||
msg.id = 123;
|
msg.id = 123;
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class InnerTupleTest extends AbstractEmbeddedCassandraTest {
|
public class InnerTupleTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
static PhotoAlbum photoAlbum;
|
static PhotoAlbum photoAlbum;
|
||||||
|
@ -41,7 +43,7 @@ public class InnerTupleTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCruid() {
|
public void testCruid() throws TimeoutException {
|
||||||
|
|
||||||
Photo photo =
|
Photo photo =
|
||||||
new Photo() {
|
new Photo() {
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class TupleTest extends AbstractEmbeddedCassandraTest {
|
public class TupleTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
static Album album;
|
static Album album;
|
||||||
|
@ -46,7 +48,7 @@ public class TupleTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCruid() {
|
public void testCruid() throws TimeoutException {
|
||||||
|
|
||||||
AlbumInformation info =
|
AlbumInformation info =
|
||||||
new AlbumInformation() {
|
new AlbumInformation() {
|
||||||
|
@ -119,7 +121,7 @@ public class TupleTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoMapping() {
|
public void testNoMapping() throws TimeoutException {
|
||||||
|
|
||||||
TupleType tupleType = session.getMetadata().newTupleType(DataType.text(), DataType.text());
|
TupleType tupleType = session.getMetadata().newTupleType(DataType.text(), DataType.text());
|
||||||
TupleValue info = tupleType.newValue();
|
TupleValue info = tupleType.newValue();
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class TupleKeyMapTest extends TupleCollectionTest {
|
public class TupleKeyMapTest extends TupleCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeyMapCRUID() {
|
public void testKeyMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 888;
|
int id = 888;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class TupleListTest extends TupleCollectionTest {
|
public class TupleListTest extends TupleCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCRUID() {
|
public void testListCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 777;
|
int id = 777;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class TupleMapTest extends TupleCollectionTest {
|
public class TupleMapTest extends TupleCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapCRUID() {
|
public void testMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 333;
|
int id = 333;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class TupleSetTest extends TupleCollectionTest {
|
public class TupleSetTest extends TupleCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetCRUID() {
|
public void testSetCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 555;
|
int id = 555;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class TupleValueMapTest extends TupleCollectionTest {
|
public class TupleValueMapTest extends TupleCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValueMapCRUID() {
|
public void testValueMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 999;
|
int id = 999;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,15 @@ import static net.helenus.core.Query.get;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UDTKeyMapTest extends UDTCollectionTest {
|
public class UDTKeyMapTest extends UDTCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeyMapCRUID() {
|
public void testKeyMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 888;
|
int id = 888;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class UDTListTest extends UDTCollectionTest {
|
public class UDTListTest extends UDTCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCRUID() {
|
public void testListCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 777;
|
int id = 777;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class UDTMapTest extends UDTCollectionTest {
|
public class UDTMapTest extends UDTCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapCRUID() {
|
public void testMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 333;
|
int id = 333;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +26,7 @@ import org.junit.Test;
|
||||||
public class UDTSetTest extends UDTCollectionTest {
|
public class UDTSetTest extends UDTCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetCRUID() {
|
public void testSetCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 555;
|
int id = 555;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,15 @@ import static net.helenus.core.Query.get;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UDTValueMapTest extends UDTCollectionTest {
|
public class UDTValueMapTest extends UDTCollectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValueMapCRUID() {
|
public void testValueMapCRUID() throws TimeoutException {
|
||||||
|
|
||||||
int id = 999;
|
int id = 999;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ package net.helenus.test.integration.core.usertype;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
|
@ -56,7 +58,7 @@ public class InnerUserDefinedTypeTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCrud() {
|
public void testCrud() throws TimeoutException {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ package net.helenus.test.integration.core.usertype;
|
||||||
import com.datastax.driver.core.UDTValue;
|
import com.datastax.driver.core.UDTValue;
|
||||||
import com.datastax.driver.core.UserType;
|
import com.datastax.driver.core.UserType;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.core.Query;
|
import net.helenus.core.Query;
|
||||||
|
@ -103,7 +105,7 @@ public class UserDefinedTypeTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMappingCRUID() {
|
public void testMappingCRUID() throws TimeoutException {
|
||||||
|
|
||||||
AddressImpl addr = new AddressImpl();
|
AddressImpl addr = new AddressImpl();
|
||||||
addr.street = "1 st";
|
addr.street = "1 st";
|
||||||
|
@ -174,7 +176,7 @@ public class UserDefinedTypeTest extends AbstractEmbeddedCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoMapping() {
|
public void testNoMapping() throws TimeoutException {
|
||||||
|
|
||||||
String ks = getSession().getLoggedKeyspace();
|
String ks = getSession().getLoggedKeyspace();
|
||||||
UserType addressType =
|
UserType addressType =
|
||||||
|
|
|
@ -20,6 +20,8 @@ import static net.helenus.core.Query.eq;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import net.helenus.core.Helenus;
|
import net.helenus.core.Helenus;
|
||||||
import net.helenus.core.HelenusSession;
|
import net.helenus.core.HelenusSession;
|
||||||
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest;
|
||||||
|
@ -56,7 +58,8 @@ public class MaterializedViewTest extends AbstractEmbeddedCassandraTest {
|
||||||
.get();
|
.get();
|
||||||
cyclist = session.dsl(Cyclist.class);
|
cyclist = session.dsl(Cyclist.class);
|
||||||
|
|
||||||
session
|
try {
|
||||||
|
session
|
||||||
.insert(cyclist)
|
.insert(cyclist)
|
||||||
.value(cyclist::cid, UUID.randomUUID())
|
.value(cyclist::cid, UUID.randomUUID())
|
||||||
.value(cyclist::age, 18)
|
.value(cyclist::age, 18)
|
||||||
|
@ -64,10 +67,12 @@ public class MaterializedViewTest extends AbstractEmbeddedCassandraTest {
|
||||||
.value(cyclist::country, "Netherlands")
|
.value(cyclist::country, "Netherlands")
|
||||||
.value(cyclist::name, "Pascal EENKHOORN")
|
.value(cyclist::name, "Pascal EENKHOORN")
|
||||||
.sync();
|
.sync();
|
||||||
|
}
|
||||||
|
catch (TimeoutException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMv() throws Exception {
|
public void testMv() throws TimeoutException {
|
||||||
session.select(Cyclist.class).from(CyclistsByAge.class).where(cyclist::age, eq(18)).sync();
|
session.select(Cyclist.class).from(CyclistsByAge.class).where(cyclist::age, eq(18)).sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue