Skip to content
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

@adamdougal
Copy link
Contributor

adamdougal commented Mar 5, 2016

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


String type = jsonObject.get("type").getAsString();

if(type.equalsIgnoreCase("any")) {

This comment has been minimized.

Copy link
@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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

Is this always serialised as a string?

This comment has been minimized.

Copy link
@adamdougal

adamdougal Mar 8, 2016

Author Contributor

I believe so

)
.build();

stubFor(get(urlEqualTo(PRIME_PREPARED_MULTI_PATH)).willReturn(aResponse().withStatus(200).withBody(

This comment has been minimized.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

We should test some other variable types

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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

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

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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

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

@@ -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.

Copy link
@chbatey
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.

Copy link
@chbatey
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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

Can extract from a tuple like:

val (variableMatchers, prime) = outcome

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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

Should never need to call isDefined

prime.fixedDelay.map(_.toMillis)
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.

Copy link
@chbatey

chbatey Mar 8, 2016

Member

Same as above

@chbatey
Copy link
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 adamdougal force-pushed the adamdougal:master branch from 1037b57 to 2e9937a Mar 8, 2016
@adamdougal adamdougal force-pushed the adamdougal:master branch from 2e9937a to 2552552 Mar 8, 2016
@adamdougal
Copy link
Contributor Author

adamdougal commented Mar 8, 2016

Commits squashed

chbatey added a commit that referenced this pull request Mar 9, 2016
Add ability to retrieve prepared multi primes
@chbatey chbatey merged commit 6383920 into scassandra:master Mar 9, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@chbatey
Copy link
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.