New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to retrieve prepared multi primes #141

Merged
merged 3 commits into from Mar 9, 2016

Conversation

Projects
None yet
2 participants
@adamdougal
Contributor

adamdougal commented Mar 5, 2016

Also changed the other retrieve end points to return fixed delay.
Might also cover #122.

Show outdated Hide outdated ...java/org/scassandra/http/client/types/GsonVariableMatchDeserialiser.java
String type = jsonObject.get("type").getAsString();
if(type.equalsIgnoreCase("any")) {

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

whitespace after the if

@chbatey

chbatey Mar 8, 2016

Member

whitespace after the if

public MultiPrimeRequest.VariableMatch deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
String type = jsonObject.get("type").getAsString();

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Is this always serialised as a string?

@chbatey

chbatey Mar 8, 2016

Member

Is this always serialised as a string?

This comment has been minimized.

@adamdougal

adamdougal Mar 8, 2016

Contributor

I believe so

@adamdougal

adamdougal Mar 8, 2016

Contributor

I believe so

Show outdated Hide outdated java-client/src/test/java/org/scassandra/http/client/PrimingClientTest.java
)
.build();
stubFor(get(urlEqualTo(PRIME_PREPARED_MULTI_PATH)).willReturn(aResponse().withStatus(200).withBody(

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

We should test some other variable types

@chbatey

chbatey Mar 8, 2016

Member

We should test some other variable types

Show outdated Hide outdated ...ala/org/scassandra/server/priming/prepared/PrimePreparedMultiStore.scala
class PrimePreparedMultiStore extends PreparedStoreLookup with LazyLogging {
var state: Map[PrimeCriteria, PreparedPrimeResult] = Map()
class PrimePreparedMultiStore extends LazyLogging with PreparedStore[PrimePreparedMulti, PreparedMultiPrime] with PreparedStoreLookup {
// todo change to a result to include validation failures etc

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Update comment, still haven't dealt with validation failures tho

@chbatey

chbatey Mar 8, 2016

Member

Update comment, still haven't dealt with validation failures tho

Show outdated Hide outdated ...a/org/scassandra/server/priming/prepared/PrimePreparedPatternStore.scala
import org.scassandra.server.priming.json.Success
import scala.concurrent.duration.FiniteDuration
class PrimePreparedPatternStore extends LazyLogging with PreparedStore with PreparedStoreLookup {
class PrimePreparedPatternStore extends LazyLogging with PreparedStore[PrimePreparedSingle, PreparedPrime] with PreparedStoreLookup {

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Switch LazyLogging and PreparedStore, doesn't make any difference but is a more accurate description of the type

@chbatey

chbatey Mar 8, 2016

Member

Switch LazyLogging and PreparedStore, doesn't make any difference but is a more accurate description of the type

Show outdated Hide outdated ...in/scala/org/scassandra/server/priming/prepared/PrimePreparedStore.scala
@@ -27,11 +27,11 @@ import org.scassandra.server.priming.routes.PrimingJsonHelper
import scala.concurrent.duration.FiniteDuration
class PrimePreparedStore extends LazyLogging with PreparedStore with PreparedStoreLookup {
class PrimePreparedStore extends LazyLogging with PreparedStore[PrimePreparedSingle, PreparedPrime] with PreparedStoreLookup {

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Same

@chbatey
Show outdated Hide outdated ...in/scala/org/scassandra/server/priming/routes/PrimingPreparedRoute.scala
case _: ClosedConnectionResult => ClosedConnection
}
val fixedDelay = if (preparedPrime.prime.fixedDelay.isDefined) Some(preparedPrime.prime.fixedDelay.get.toMillis) else None
val result = PrimingJsonHelper.convertToResultJsonRepresentation(preparedPrime.getPrime().result)

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

nice

@chbatey
Show outdated Hide outdated ...in/scala/org/scassandra/server/priming/routes/PrimingPreparedRoute.scala
val preparedPrimes: Iterable[PrimePreparedMulti] = primePreparedMultiStore.retrievePrimes().map({ case (primeCriteria, preparedPrime) =>
val outcomes : List[Outcome] = preparedPrime.variableMatchers.map({ case (outcome) =>
val variableMatchers: List[VariableMatch] = outcome._1

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Can extract from a tuple like:

val (variableMatchers, prime) = outcome
@chbatey

chbatey Mar 8, 2016

Member

Can extract from a tuple like:

val (variableMatchers, prime) = outcome
Show outdated Hide outdated ...in/scala/org/scassandra/server/priming/routes/PrimingPreparedRoute.scala
val prime: Prime = outcome._2
val result = PrimingJsonHelper.convertToResultJsonRepresentation(prime.result)
val fixedDelay = if (prime.fixedDelay.isDefined) Some(prime.fixedDelay.get.toMillis) else None

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Should never need to call isDefined

prime.fixedDelay.map(_.toMillis)
@chbatey

chbatey Mar 8, 2016

Member

Should never need to call isDefined

prime.fixedDelay.map(_.toMillis)
Show outdated Hide outdated ...in/scala/org/scassandra/server/priming/routes/PrimingPreparedRoute.scala
case _: UnpreparedResult => Unprepared
case _: ClosedConnectionResult => ClosedConnection
}
val fixedDelay = if (preparedPrime.prime.fixedDelay.isDefined) Some(preparedPrime.prime.fixedDelay.get.toMillis) else None

This comment has been minimized.

@chbatey

chbatey Mar 8, 2016

Member

Same as above

@chbatey

chbatey Mar 8, 2016

Member

Same as above

@chbatey

This comment has been minimized.

Show comment
Hide comment
@chbatey

chbatey Mar 8, 2016

Member

This looks really good, just a few minor comments. Once you've addressed them could you please squash your commits.

Member

chbatey commented Mar 8, 2016

This looks really good, just a few minor comments. Once you've addressed them could you please squash your commits.

@adamdougal

This comment has been minimized.

Show comment
Hide comment
@adamdougal

adamdougal Mar 8, 2016

Contributor

Commits squashed

Contributor

adamdougal commented Mar 8, 2016

Commits squashed

chbatey added a commit that referenced this pull request Mar 9, 2016

Merge pull request #141 from adamdougal/master
Add ability to retrieve prepared multi primes

@chbatey chbatey merged commit 6383920 into scassandra:master Mar 9, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@chbatey

This comment has been minimized.

Show comment
Hide comment
@chbatey

chbatey Mar 9, 2016

Member

Looks good

Member

chbatey commented Mar 9, 2016

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment