Skip to content

Commit

Permalink
Fixed overzealous search and replace.
Browse files Browse the repository at this point in the history
--Looks like I accidentally replaced all instances of "jobs" with
"async" rather than just the package name.
  • Loading branch information
archolewa committed Aug 31, 2016
1 parent 1e64a20 commit 6b26d95
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ protected ApiJobStore buildApiJobStore() {
}

/**
* Builds an instance of a BroadcastChannel that broadcasts the tickets of asynchronous async that have been
* Builds an instance of a BroadcastChannel that broadcasts the tickets of asynchronous jobs that have been
* successfully stored in the PreResponseStore .
*
* @return A BroadcastChannel that allows Bard to talk to other Bard processes, by default returns the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the terms of the Apache license. Please see LICENSE file distributed with this work for terms.
package com.yahoo.bard.webservice.async.broadcastchannels;

import com.yahoo.bard.webservice.async.broadcastchannels.BroadcastChannel;

import rx.Observable;
import rx.subjects.Subject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface JobPayloadBuilder {
/**
* Get the job results url.
* <pre>
* "http://localhost:9998/async/ticket1/results"
* "http://localhost:9998/jobs/ticket1/results"
* </pre>
*
* @param ticket The ticket that can uniquely identify a Job
Expand All @@ -45,7 +45,7 @@ static String getResultsUrl(String ticket, UriInfo uriInfo) {
/**
* Get the url for obtaining the job results synchronously.
* <pre>
* "http://localhost:9998/async/ticket1/results?async=never"
* "http://localhost:9998/jobs/ticket1/results?asyncAfter=never"
* </pre>
*
* @param ticket The ticket that can uniquely identify a Job
Expand All @@ -61,11 +61,11 @@ static String getSyncResultsUrl(String ticket, UriInfo uriInfo) {
}

/**
* Get the UriBuilder for the /job/ticket/results endpoint.
* Get the UriBuilder for the /jobs/ticket/results endpoint.
*
* @param uriInfo UriInfo of the request
*
* @return the UriBuilder for the /job/ticket/results endpoint
* @return the UriBuilder for the /jobs/ticket/results endpoint
*/
static UriBuilder getResultsBaseUrl(UriInfo uriInfo) {
return uriInfo.getBaseUriBuilder()
Expand All @@ -76,7 +76,7 @@ static UriBuilder getResultsBaseUrl(UriInfo uriInfo) {
/**
* Get the url for the given ticket.
* <pre>
* "http://localhost:9998/async/ticket1"
* "http://localhost:9998/jobs/ticket1"
* </pre>
*
* @param ticket The ticket that can uniquely identify a Job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import rx.Observable;

/**
* An ApiJobStore is responsible for storing the metadata about Bard async. Conceptually, the ApiJobStore is a table
* An ApiJobStore is responsible for storing the metadata about Bard jobs. Conceptually, the ApiJobStore is a table
* where each row is the metadata of a particular job, and the columns are the metadata stored with each job
* (such metadata may include date created, a link to results, etc). The table uses the job's id as the primary
* key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* An ApiJobStore backed by an in-memory map. This is meant as a stub implementation for
* testing and playing purposes. It is _not_ meant to be used in production. For one, it stores the ticket
* information in memory, which is not durable. For another, it does not attempt to cleanup sufficiently old async,
* information in memory, which is not durable. For another, it does not attempt to cleanup sufficiently old jobs,
* so its memory footprint will grow until the system is rebooted.
*/
public class HashJobStore implements ApiJobStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public class JobRequest implements LogInfo {
protected final String resource = "async";
protected final String resource = "jobs";
protected final String ticket;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package com.yahoo.bard.webservice.web;

/**
* Unchecked exception in case request to the async endpoint fails.
* Unchecked exception in case request to the jobs endpoint fails.
*/
public class JobRequestFailedException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public JobsApiRequest(
}

/**
* Return an Observable over the Map representing the job to be returned to the user.
* Returns an Observable over the Map representing the job to be returned to the user.
*
* @param ticket The ticket that uniquely identifies the job
*
Expand Down Expand Up @@ -112,9 +112,9 @@ public Observable<PreResponse> handleBroadcastChannelNotification(@NotNull Strin
}

/**
* Return an Observable containing a stream of job payloads for all the async in the ApiJobStore. If, for any JobRow,
* the mapping from JobRow to job view fails, an Observable over JobRequestFailedException is returned.
* If the ApiJobStore is empty, we return an empty Observable.
* Returns an Observable containing a stream of job payloads for all the jobs in the ApiJobStore. If, for any
* JobRow, the mapping from JobRow to job view fails, an Observable over JobRequestFailedException is returned. If
* the ApiJobStore is empty, we return an empty Observable.
*
* @return An Observable containing a stream of Maps representing the job to be returned to the user
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
/**
* Resource code for job resource endpoints.
*/
@Path("/async")
@Path("/jobs")
@Singleton
public class JobsServlet extends EndpointServlet {

Expand Down Expand Up @@ -167,7 +167,7 @@ public void getJobs(
apiRequest.getJobViews()
.toList()
.map(jobs -> jobsApiRequest.getPage(paginationFactory.apply(jobs)))
.map(result -> formatResponse(jobsApiRequest, result, "async", null))
.map(result -> formatResponse(jobsApiRequest, result, "jobs", null))
.defaultIfEmpty(getResponse("{}"))
.onErrorReturn(this::getErrorResponse)
.subscribe(
Expand Down Expand Up @@ -238,7 +238,7 @@ public void getJobByTicket(
}

/**
* Endpoint to get a particular async result.
* Endpoint to get a particular job's result.
*
* @param ticket The ticket that can uniquely identify a Job
* @param format Requested format of the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
// Licensed under the terms of the Apache license. Please see LICENSE file distributed with this work for terms.
package com.yahoo.bard.webservice.async.jobs.jobrows

import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.DATE_CREATED_DATA
import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.DATE_UPDATED_DATA
import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.JOB_TICKET_DATA
import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.QUERY_DATA
import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.STATUS_DATA
import static com.yahoo.bard.webservice.async.jobs.JobTestUtils.USER_ID_DATA
import static com.yahoo.bard.webservice.async.jobs.jobrows.DefaultJobField.JOB_TICKET
import static com.yahoo.bard.webservice.async.jobs.jobrows.DefaultJobField.QUERY
import static com.yahoo.bard.webservice.async.jobs.jobrows.DefaultJobField.STATUS
Expand Down Expand Up @@ -30,12 +36,12 @@ class JobRowSpec extends Specification {

and: "The expected map"
Map<String, String> expectedMap = [
jobTicket: JobTestUtils.JOB_TICKET_DATA,
query: JobTestUtils.QUERY_DATA,
status: JobTestUtils.STATUS_DATA,
dateCreated: JobTestUtils.DATE_CREATED_DATA,
dateUpdated: JobTestUtils.DATE_UPDATED_DATA,
userId: JobTestUtils.USER_ID_DATA
jobTicket: JOB_TICKET_DATA,
query: QUERY_DATA,
status: STATUS_DATA,
dateCreated: DATE_CREATED_DATA,
dateUpdated: DATE_UPDATED_DATA,
userId: USER_ID_DATA
]

expect:
Expand All @@ -49,12 +55,12 @@ class JobRowSpec extends Specification {
and: "The expected JSON"
JsonNode expected = MAPPER.readTree(
"""{
"query": "$JobTestUtils.QUERY_DATA",
"status": "$JobTestUtils.STATUS_DATA",
"jobTicket": "$JobTestUtils.JOB_TICKET_DATA",
"dateCreated": "$JobTestUtils.DATE_CREATED_DATA",
"dateUpdated": "$JobTestUtils.DATE_UPDATED_DATA",
"userId": "$JobTestUtils.USER_ID_DATA"
"query": "$QUERY_DATA",
"status": "$STATUS_DATA",
"jobTicket": "$JOB_TICKET_DATA",
"dateCreated": "$DATE_CREATED_DATA",
"dateUpdated": "$DATE_UPDATED_DATA",
"userId": "$USER_ID_DATA"
}"""
)

Expand All @@ -73,9 +79,9 @@ class JobRowSpec extends Specification {
//Everything is different
false | JobTestUtils.buildJobRow(1) | JobTestUtils.buildJobRow(2)
// Different id fields
false | JobTestUtils.buildJobRow() | JobTestUtils.buildJobRow([(JOB_TICKET): JobTestUtils.JOB_TICKET_DATA + "!"])
false | JobTestUtils.buildJobRow() | JobTestUtils.buildJobRow([(JOB_TICKET): JOB_TICKET_DATA + "!"])
// Different non-id fields
false | JobTestUtils.buildJobRow() | JobTestUtils.buildJobRow([(QUERY): JobTestUtils.QUERY_DATA + ",aMetric"])
false | JobTestUtils.buildJobRow() | JobTestUtils.buildJobRow([(QUERY): QUERY_DATA + ",aMetric"])

equalityOperation = truefalse ? {row1, row2 -> row1 == row2} : {row1, row2 -> row1 != row2}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package com.yahoo.bard.webservice.async.jobs.payloads

import com.yahoo.bard.webservice.async.jobs.jobrows.DefaultJobField
import com.yahoo.bard.webservice.async.jobs.payloads.DefaultJobPayloadBuilder
import com.yahoo.bard.webservice.async.jobs.jobrows.JobField
import com.yahoo.bard.webservice.async.jobs.jobrows.JobRow
import com.yahoo.bard.webservice.web.JobRequestFailedException
Expand Down Expand Up @@ -32,20 +31,20 @@ class DefaultJobPayloadBuilderSpec extends Specification {
def "JobRow is mapped correctly to the job to be displayed to the end user"() {
setup:
Map<JobField, String> fieldValueMap = [
(DefaultJobField.JOB_TICKET) :"ticket1",
(DefaultJobField.JOB_TICKET):"ticket1",
(DefaultJobField.DATE_CREATED): "2016-01-01",
(DefaultJobField.DATE_UPDATED): "2016-01-01",
(DefaultJobField.QUERY) : "https://localhost:9998/v1/data/QUERY",
(DefaultJobField.STATUS) : "success",
(DefaultJobField.USER_ID) : "momo"
(DefaultJobField.QUERY): "https://localhost:9998/v1/data/QUERY",
(DefaultJobField.STATUS): "success",
(DefaultJobField.USER_ID): "momo"
]
JobRow jobRow = new JobRow(DefaultJobField.JOB_TICKET, fieldValueMap)

Map<String, String> job = [
query: "https://localhost:9998/v1/data/QUERY",
results: "https://localhost:9998/v1/async/ticket1/results",
syncResults: "https://localhost:9998/v1/async/ticket1/results?asyncAfter=never",
self: "https://localhost:9998/v1/async/ticket1",
results: "https://localhost:9998/v1/jobs/ticket1/results",
syncResults: "https://localhost:9998/v1/jobs/ticket1/results?asyncAfter=never",
self: "https://localhost:9998/v1/jobs/ticket1",
status: "success",
jobTicket: "ticket1",
dateCreated: "2016-01-01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the terms of the Apache license. Please see LICENSE file distributed with this work for terms.
package com.yahoo.bard.webservice.async.jobs.payloads

import com.yahoo.bard.webservice.async.jobs.payloads.JobPayloadBuilder

import spock.lang.Specification

import javax.ws.rs.core.UriBuilder
Expand All @@ -24,16 +22,16 @@ class JobPayLoadBuilderSpec extends Specification {

def "We are able to get the correct results url"() {
expect:
JobPayloadBuilder.getResultsUrl("ticket1", uriInfo) == "https://localhost:9998/v1/async/ticket1/results"
JobPayloadBuilder.getResultsUrl("ticket1", uriInfo) == "https://localhost:9998/v1/jobs/ticket1/results"
}

def "We are able to get the correct syncResults url"() {
expect:
JobPayloadBuilder.getSyncResultsUrl("ticket1", uriInfo) == "https://localhost:9998/v1/async/ticket1/results?asyncAfter=never"
JobPayloadBuilder.getSyncResultsUrl("ticket1", uriInfo) == "https://localhost:9998/v1/jobs/ticket1/results?asyncAfter=never"
}

def "We are able to get the correct self url"() {
expect:
JobPayloadBuilder.getSelfUrl("ticket1", uriInfo) == "https://localhost:9998/v1/async/ticket1"
JobPayloadBuilder.getSelfUrl("ticket1", uriInfo) == "https://localhost:9998/v1/jobs/ticket1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class JobsApiRequestSpec extends Specification {
TestSubscriber<Map<String, String>> getSubscriber = new TestSubscriber<>()
Map<String, String> job = [
query: "https://localhost:9998/v1/data/QUERY",
results: "https://localhost:9998/v1/async/ticket1/results",
syncResults: "https://localhost:9998/v1/async/ticket1/results?asyncAfter=never",
self: "https://localhost:9998/v1/async/ticket1",
results: "https://localhost:9998/v1/jobs/ticket1/results",
syncResults: "https://localhost:9998/v1/jobs/ticket1/results?asyncAfter=never",
self: "https://localhost:9998/v1/jobs/ticket1",
status: "success",
jobTicket: "ticket1",
dateCreated: "2016-01-01"
Expand Down
Loading

0 comments on commit 6b26d95

Please sign in to comment.