-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Jackson for JSON de/serialization
This involves a major refactor of all message representations. The main motivation for this change is to simplify the logic to enforce type safety, such that we no longer depend on the behavior of all the scala class magic we used to rely on. This commit also introduces a differentiation between request and response messages to provide further type safety. This would have introduced much additional complexity without the refactor.
- Loading branch information
Andrew Or
committed
Jan 29, 2015
1 parent
d7a1f9f
commit df90e8b
Showing
23 changed files
with
910 additions
and
1,071 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
core/src/main/scala/org/apache/spark/deploy/rest/DriverStatusRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.deploy.rest | ||
|
||
class DriverStatusRequest extends SubmitRestProtocolRequest { | ||
protected override val action = SubmitRestProtocolAction.DRIVER_STATUS_REQUEST | ||
private val driverId = new SubmitRestProtocolField[String] | ||
|
||
def getDriverId: String = driverId.toString | ||
def setDriverId(s: String): this.type = setField(driverId, s) | ||
|
||
override def validate(): Unit = { | ||
super.validate() | ||
assertFieldIsSet(driverId, "driver_id") | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
core/src/main/scala/org/apache/spark/deploy/rest/DriverStatusRequestMessage.scala
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
core/src/main/scala/org/apache/spark/deploy/rest/DriverStatusResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.deploy.rest | ||
|
||
class DriverStatusResponse extends SubmitRestProtocolResponse { | ||
protected override val action = SubmitRestProtocolAction.DRIVER_STATUS_RESPONSE | ||
private val driverId = new SubmitRestProtocolField[String] | ||
private val success = new SubmitRestProtocolField[Boolean] | ||
private val driverState = new SubmitRestProtocolField[String] | ||
private val workerId = new SubmitRestProtocolField[String] | ||
private val workerHostPort = new SubmitRestProtocolField[String] | ||
|
||
def getDriverId: String = driverId.toString | ||
def getSuccess: String = success.toString | ||
def getDriverState: String = driverState.toString | ||
def getWorkerId: String = workerId.toString | ||
def getWorkerHostPort: String = workerHostPort.toString | ||
|
||
def setDriverId(s: String): this.type = setField(driverId, s) | ||
def setSuccess(s: String): this.type = setBooleanField(success, s) | ||
def setDriverState(s: String): this.type = setField(driverState, s) | ||
def setWorkerId(s: String): this.type = setField(workerId, s) | ||
def setWorkerHostPort(s: String): this.type = setField(workerHostPort, s) | ||
|
||
override def validate(): Unit = { | ||
super.validate() | ||
assertFieldIsSet(driverId, "driver_id") | ||
assertFieldIsSet(success, "success") | ||
} | ||
} |
52 changes: 0 additions & 52 deletions
52
core/src/main/scala/org/apache/spark/deploy/rest/DriverStatusResponseMessage.scala
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
core/src/main/scala/org/apache/spark/deploy/rest/ErrorMessage.scala
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
core/src/main/scala/org/apache/spark/deploy/rest/ErrorResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.deploy.rest | ||
|
||
class ErrorResponse extends SubmitRestProtocolResponse { | ||
protected override val action = SubmitRestProtocolAction.ERROR | ||
override def validate(): Unit = { | ||
super.validate() | ||
assertFieldIsSet(message, "message") | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/main/scala/org/apache/spark/deploy/rest/KillDriverRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.deploy.rest | ||
|
||
class KillDriverRequest extends SubmitRestProtocolRequest { | ||
protected override val action = SubmitRestProtocolAction.KILL_DRIVER_REQUEST | ||
private val driverId = new SubmitRestProtocolField[String] | ||
|
||
def getDriverId: String = driverId.toString | ||
def setDriverId(s: String): this.type = setField(driverId, s) | ||
|
||
override def validate(): Unit = { | ||
super.validate() | ||
assertFieldIsSet(driverId, "driver_id") | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
core/src/main/scala/org/apache/spark/deploy/rest/KillDriverRequestMessage.scala
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
core/src/main/scala/org/apache/spark/deploy/rest/KillDriverResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.deploy.rest | ||
|
||
class KillDriverResponse extends SubmitRestProtocolResponse { | ||
protected override val action = SubmitRestProtocolAction.KILL_DRIVER_RESPONSE | ||
private val driverId = new SubmitRestProtocolField[String] | ||
private val success = new SubmitRestProtocolField[Boolean] | ||
|
||
def getDriverId: String = driverId.toString | ||
def getSuccess: String = success.toString | ||
|
||
def setDriverId(s: String): this.type = setField(driverId, s) | ||
def setSuccess(s: String): this.type = setBooleanField(success, s) | ||
|
||
override def validate(): Unit = { | ||
super.validate() | ||
assertFieldIsSet(driverId, "driver_id") | ||
assertFieldIsSet(success, "success") | ||
} | ||
} |
Oops, something went wrong.